private static String composeFormula(FormulaRecord record)
{
- return HSSFFormulaParser.toFormulaString((HSSFWorkbook)null, record.getParsedExpression());
+ return HSSFFormulaParser.toFormulaString(null, record.getParsedExpression());
}
/**
thisRow = frec.getRow();
if(_formulasNotResults) {
- thisText = HSSFFormulaParser.toFormulaString((HSSFWorkbook)null, frec.getParsedExpression());
+ thisText = HSSFFormulaParser.toFormulaString(null, frec.getParsedExpression());
} else {
if(frec.hasCachedResultString()) {
// Formula result is a string
sp.setShapeId(shapeId);
} else if (recordId == EscherOptRecord.RECORD_ID){
EscherOptRecord opt = (EscherOptRecord)shapeChildRecord;
- EscherSimpleProperty prop = (EscherSimpleProperty)opt.lookup(
+ EscherSimpleProperty prop = opt.lookup(
EscherProperties.BLIP__BLIPTODISPLAY );
if (prop != null){
int pictureIndex = prop.getPropertyValue();
}
for (NoteRecord noteRecord : tailRec.values()) {
- Record rec = (Record) noteRecord;
+ Record rec = noteRecord;
pos += rec.serialize(pos, data);
}
int bytesWritten = pos - offset;
*/
public void setMainSpRecordId(int shapeId) {
EscherContainerRecord dgContainer = getEscherContainer();
- EscherContainerRecord spgrConatiner = (EscherContainerRecord) dgContainer.getChildById(EscherContainerRecord.SPGR_CONTAINER);
+ EscherContainerRecord spgrConatiner = dgContainer.getChildById(EscherContainerRecord.SPGR_CONTAINER);
EscherContainerRecord spContainer = (EscherContainerRecord) spgrConatiner.getChild(0);
- EscherSpRecord sp = (EscherSpRecord) spContainer.getChildById(EscherSpRecord.RECORD_ID);
+ EscherSpRecord sp = spContainer.getChildById(EscherSpRecord.RECORD_ID);
sp.setShapeId(shapeId);
}
short[] xfs = new short[nBlank];
for (int i = 0; i < xfs.length; i++) {
- xfs[i] = ((BlankRecord)cellValues[startIx + i]).getXFIndex();
+ xfs[i] = cellValues[startIx + i].getXFIndex();
}
int rowIx = cellValues[startIx].getRow();
return new MulBlankRecord(rowIx, startIx, xfs);
* The filename of the embedded image
*/
public String getFileName() {
- EscherComplexProperty propFile = (EscherComplexProperty) getOptRecord().lookup(
+ EscherComplexProperty propFile = getOptRecord().lookup(
EscherProperties.BLIP__BLIPFILENAME);
return (null == propFile)
? ""
*/
public void applyFont(int startIndex, int endIndex, Font font)
{
- applyFont(startIndex, endIndex, ((HSSFFont) font).getIndex());
+ applyFont(startIndex, endIndex, font.getIndex());
}
/**
*/
@Override
public void setDefaultColumnStyle(int column, CellStyle style) {
- _sheet.setDefaultColumnStyle(column, ((HSSFCellStyle) style).getIndex());
+ _sheet.setDefaultColumnStyle(column, style.getIndex());
}
/**
final OPOIFSFileSystem filesystem,
final DirectoryNode parent)
{
- this(property, parent, filesystem, (NPOIFSFileSystem)null);
+ this(property, parent, filesystem, null);
}
/**
final NPOIFSFileSystem nfilesystem,
final DirectoryNode parent)
{
- this(property, parent, (OPOIFSFileSystem)null, nfilesystem);
+ this(property, parent, null, nfilesystem);
}
private DirectoryNode(final DirectoryProperty property,
*/
@Internal
public static void copyNodeRecursively( Entry entry, DirectoryEntry target )
- throws IOException
- {
+ throws IOException {
// logger.log( POILogger.ERROR, "copyNodeRecursively called with "+entry.getName()+
// ","+target.getName());
- DirectoryEntry newTarget = null;
- if ( entry.isDirectoryEntry() )
- {
+ if ( entry.isDirectoryEntry() ) {
DirectoryEntry dirEntry = (DirectoryEntry)entry;
- newTarget = target.createDirectory( entry.getName() );
+ DirectoryEntry newTarget = target.createDirectory( entry.getName() );
newTarget.setStorageClsid( dirEntry.getStorageClsid() );
Iterator<Entry> entries = dirEntry.getEntries();
- while ( entries.hasNext() )
- {
+ while ( entries.hasNext() ) {
copyNodeRecursively( entries.next(), newTarget );
}
- }
- else
- {
+ } else {
DocumentEntry dentry = (DocumentEntry) entry;
DocumentInputStream dstream = new DocumentInputStream( dentry );
target.createDocument( dentry.getName(), dstream );
* is the target Directory to copy to
*/
public static void copyNodes(DirectoryEntry sourceRoot,
- DirectoryEntry targetRoot) throws IOException
- {
+ DirectoryEntry targetRoot) throws IOException {
for (Entry entry : sourceRoot) {
copyNodeRecursively( entry, targetRoot );
}
}
- /**
- * Copies nodes from one Directory to the other minus the excepts
- *
- * @param filteredSource The filtering source Directory to copy from
- * @param filteredTarget The filtering target Directory to copy to
- */
- public static void copyNodes( FilteringDirectoryNode filteredSource,
- FilteringDirectoryNode filteredTarget ) throws IOException
- {
- // Nothing special here, just overloaded types to make the
- // recommended new way to handle this clearer
- copyNodes( (DirectoryEntry)filteredSource, (DirectoryEntry)filteredTarget );
- }
-
/**
* Copies all nodes from one POIFS to the other
*
{
if (preferArray())
{
- return (( POIFSViewable ) getRoot()).getViewableArray();
+ return getRoot().getViewableArray();
}
return new Object[ 0 ];
}
{
if (!preferArray())
{
- return (( POIFSViewable ) getRoot()).getViewableIterator();
+ return getRoot().getViewableIterator();
}
return Collections.emptyList().iterator();
}
public boolean preferArray()
{
- return (( POIFSViewable ) getRoot()).preferArray();
+ return getRoot().preferArray();
}
/**
Property property = properties.next();
String name = property.getName();
DirectoryNode parent = (dir == null)
- ? (( DirectoryNode ) getRoot())
+ ? getRoot()
: dir;
if (property.isDirectory())
{
if (preferArray())
{
- return (( POIFSViewable ) getRoot()).getViewableArray();
+ return getRoot().getViewableArray();
}
return new Object[ 0 ];
}
{
if (!preferArray())
{
- return (( POIFSViewable ) getRoot()).getViewableIterator();
+ return getRoot().getViewableIterator();
}
return Collections.emptyList().iterator();
}
public boolean preferArray()
{
- return (( POIFSViewable ) getRoot()).preferArray();
+ return getRoot().preferArray();
}
/**
SheetRangeEvaluator sre = new SheetRangeEvaluator(_sheetIndex, se);
// ugly typecast - TODO - make spreadsheet version more easily accessible
- SpreadsheetVersion ssVersion = ((FormulaParsingWorkbook)_workbook).getSpreadsheetVersion();
+ SpreadsheetVersion ssVersion = _workbook.getSpreadsheetVersion();
NameType part1refType = classifyCellReference(refStrPart1, ssVersion);
switch (part1refType) {
case BAD_CELL_OR_NAMED_RANGE:
return ErrorEval.REF_INVALID;
case NAMED_RANGE:
- EvaluationName nm = ((FormulaParsingWorkbook)_workbook).getName(refStrPart1, _sheetIndex);
+ EvaluationName nm = _workbook.getName(refStrPart1, _sheetIndex);
if(!nm.isRange()){
throw new RuntimeException("Specified name '" + refStrPart1 + "' is not a range as expected.");
}
throw new RuntimeException("Array item cannot be null");
}
if (o instanceof String) {
- return "\"" + (String)o + "\"";
+ return "\"" + o + "\"";
}
if (o instanceof Double) {
return NumberToTextConverter.toText(((Double)o).doubleValue());
* @return Java representation of the date, or null if date is not a valid Excel date
*/
public static Calendar getJavaCalendar(double date) {
- return getJavaCalendar(date, false, (TimeZone)null, false);
+ return getJavaCalendar(date, false, null, false);
}
/**
* @return Java representation of the date, or null if date is not a valid Excel date
*/
public static Calendar getJavaCalendar(double date, boolean use1904windowing) {
- return getJavaCalendar(date, use1904windowing, (TimeZone)null, false);
+ return getJavaCalendar(date, use1904windowing, null, false);
}
/**
if (relType == null) {
throw new IllegalArgumentException("Picture type "+format+" is not supported.");
}
- img = (XSLFPictureData) createRelationship(relType, XSLFFactory.getInstance(), imageNumber + 1, true).getDocumentPart();
+ img = createRelationship(relType, XSLFFactory.getInstance(), imageNumber + 1, true).getDocumentPart();
img.setIndex(imageNumber);
_pictures.add(img);
try {
private int findStartOfRowOutlineGroup(int rowIndex) {
// Find the start of the group.
Row row = getRow(rowIndex);
- int level = ((SXSSFRow) row).getOutlineLevel();
+ int level = row.getOutlineLevel();
if(level == 0) {
throw new IllegalArgumentException("Outline level is zero for the row (" + rowIndex + ").");
}
@Override
public int addPicture(byte[] pictureData, int format) {
int imageNumber = getAllPictures().size() + 1;
- XSSFPictureData img = (XSSFPictureData)createRelationship(XSSFPictureData.RELATIONS[format], XSSFFactory.getInstance(), imageNumber, true).getDocumentPart();
+ XSSFPictureData img = createRelationship(XSSFPictureData.RELATIONS[format], XSSFFactory.getInstance(), imageNumber, true).getDocumentPart();
try {
OutputStream out = img.getPackagePart().getOutputStream();
out.write(pictureData);
* in the body. Otherwise, take the previous paragraph and calculate
* the new index for the new paragraph.
*/
- if ((!(o instanceof CTP)) || (CTP) o == p) {
+ if ((!(o instanceof CTP)) || o == p) {
paragraphs.add(0, newP);
} else {
int pos = paragraphs.indexOf(getParagraph((CTP) o)) + 1;
while (!(o instanceof CTP) && (cursor.toPrevSibling())) {
o = cursor.getObject();
}
- if ((!(o instanceof CTP)) || (CTP) o == p) {
+ if ((!(o instanceof CTP)) || o == p) {
paragraphs.add(0, newP);
} else {
int pos = paragraphs.indexOf(getParagraph((CTP) o)) + 1;
while (!(o instanceof CTP) && (cursor.toPrevSibling())) {
o = cursor.getObject();
}
- if ((!(o instanceof CTP)) || (CTP) o == p) {
+ if ((!(o instanceof CTP)) || o == p) {
paragraphs.add(0, newP);
} else {
int pos = paragraphs.indexOf(getParagraph((CTP) o)) + 1;
text.append(((XWPFSDT) o).getContent().getText());
addNewLine = true;
} else if (o instanceof XWPFRun) {
- text.append(((XWPFRun) o));
+ text.append(o);
addNewLine = false;
}
if (addNewLine == true && i < bodyElements.size() - 1) {
while (!(o instanceof CTP) && (cursor.toPrevSibling())) {
o = cursor.getObject();
}
- if ((!(o instanceof CTP)) || (CTP) o == p) {
+ if ((!(o instanceof CTP)) || o == p) {
paragraphs.add(0, newP);
} else {
int pos = paragraphs.indexOf(getParagraph((CTP) o)) + 1;
RelationPart rp = rels.get(0);
assertTrue(rp.getDocumentPart() instanceof XSSFDrawing);
- XSSFDrawing drawing = (XSSFDrawing)rp.getDocumentPart();
+ XSSFDrawing drawing = rp.getDocumentPart();
//sheet.createDrawingPatriarch() should return the same instance of XSSFDrawing
assertSame(drawing, sheet.createDrawingPatriarch());
String drawingId = rp.getRelationship().getId();
assertEquals(0, ((NameXPxg)ptgs[0]).getExternalWorkbookNumber());
assertEquals(null, ((NameXPxg)ptgs[0]).getSheetName());
assertEquals("NR_Global_B2",((NameXPxg)ptgs[0]).getNameName());
- assertEquals("[0]!NR_Global_B2",((NameXPxg)ptgs[0]).toFormulaString());
+ assertEquals("[0]!NR_Global_B2", ptgs[0].toFormulaString());
wb.close();
}
assertEquals(Ref3DPxg.class, ptgs[0].getClass());
assertEquals(-1, ((Ref3DPxg)ptgs[0]).getExternalWorkbookNumber());
assertEquals("A1", ((Ref3DPxg)ptgs[0]).format2DRefAsString());
- assertEquals("Uses!A1", ((Ref3DPxg)ptgs[0]).toFormulaString());
+ assertEquals("Uses!A1", ptgs[0].toFormulaString());
// Reference to a single cell in a different sheet, which needs quoting
ptgs = parse(fpb, "'Testing 47100'!A1");
assertEquals(-1, ((Ref3DPxg)ptgs[0]).getExternalWorkbookNumber());
assertEquals("Testing 47100", ((Ref3DPxg)ptgs[0]).getSheetName());
assertEquals("A1", ((Ref3DPxg)ptgs[0]).format2DRefAsString());
- assertEquals("'Testing 47100'!A1", ((Ref3DPxg)ptgs[0]).toFormulaString());
+ assertEquals("'Testing 47100'!A1", ptgs[0].toFormulaString());
// Reference to a sheet scoped named range from another sheet
ptgs = parse(fpb, "Defines!NR_To_A1");
assertEquals(-1, ((NameXPxg)ptgs[0]).getExternalWorkbookNumber());
assertEquals("Defines", ((NameXPxg)ptgs[0]).getSheetName());
assertEquals("NR_To_A1",((NameXPxg)ptgs[0]).getNameName());
- assertEquals("Defines!NR_To_A1",((NameXPxg)ptgs[0]).toFormulaString());
+ assertEquals("Defines!NR_To_A1", ptgs[0].toFormulaString());
// Reference to a workbook scoped named range
ptgs = parse(fpb, "NR_Global_B2");
assertEquals(1, ((Ref3DPxg)ptgs[0]).getExternalWorkbookNumber());
assertEquals("Uses",((Ref3DPxg)ptgs[0]).getSheetName());
assertEquals("$A$1",((Ref3DPxg)ptgs[0]).format2DRefAsString());
- assertEquals("[1]Uses!$A$1",((Ref3DPxg)ptgs[0]).toFormulaString());
+ assertEquals("[1]Uses!$A$1", ptgs[0].toFormulaString());
// Reference to a sheet-scoped named range in a different workbook
ptgs = parse(fpb, "[1]Defines!NR_To_A1");
assertEquals(1, ((NameXPxg)ptgs[0]).getExternalWorkbookNumber());
assertEquals("Defines", ((NameXPxg)ptgs[0]).getSheetName());
assertEquals("NR_To_A1",((NameXPxg)ptgs[0]).getNameName());
- assertEquals("[1]Defines!NR_To_A1",((NameXPxg)ptgs[0]).toFormulaString());
+ assertEquals("[1]Defines!NR_To_A1", ptgs[0].toFormulaString());
// Reference to a global named range in a different workbook
ptgs = parse(fpb, "[1]!NR_Global_B2");
assertEquals(1, ((NameXPxg)ptgs[0]).getExternalWorkbookNumber());
assertEquals(null, ((NameXPxg)ptgs[0]).getSheetName());
assertEquals("NR_Global_B2",((NameXPxg)ptgs[0]).getNameName());
- assertEquals("[1]!NR_Global_B2",((NameXPxg)ptgs[0]).toFormulaString());
+ assertEquals("[1]!NR_Global_B2", ptgs[0].toFormulaString());
wb.close();
}
// ensure that a memory based package part does not have lingering data from previous commit() calls
if(sheetBack.getPackagePart() instanceof MemoryPackagePart) {
- ((MemoryPackagePart)sheetBack.getPackagePart()).clear();
+ sheetBack.getPackagePart().clear();
}
sheetBack.commit();
escherRecord.setRecordId(recordId);
escherRecord.setOptions(options);
if (escherRecord instanceof EscherContainerRecord) {
- ((EscherContainerRecord)escherRecord).fillFields(data, offset, this);
+ escherRecord.fillFields(data, offset, this);
}
return escherRecord;
// NOFILLHITTEST can be in the normal escher opt record but also in the tertiary record
// the extended bit fields seem to be in the second
- opt = (AbstractEscherOptRecord)shape.getEscherChild(RecordTypes.EscherUserDefined);
+ opt = shape.getEscherChild(RecordTypes.EscherUserDefined);
EscherSimpleProperty p = HSLFShape.getEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST);
int propVal = (p == null) ? 0 : p.getPropertyValue();
final boolean rotateWithShape = FILL_USE_USE_SHAPE_ANCHOR.isSet(propVal) && FILL_USE_SHAPE_ANCHOR.isSet(propVal);
if (exobj != null && cldata != null) {
List<HSLFHyperlink> lst = new ArrayList<HSLFHyperlink>();
find(cldata.getHSLFChildRecords(), exobj, lst);
- return lst.isEmpty() ? null : (HSLFHyperlink)lst.get(0);
+ return lst.isEmpty() ? null : lst.get(0);
}
return null;
EscherSpRecord spRecord = getEscherChild(EscherSpRecord.RECORD_ID);
int flags = spRecord.getFlags();
if ((flags & EscherSpRecord.FLAG_CHILD) != 0){
- EscherChildAnchorRecord rec = (EscherChildAnchorRecord)getEscherChild(EscherChildAnchorRecord.RECORD_ID);
+ EscherChildAnchorRecord rec = getEscherChild(EscherChildAnchorRecord.RECORD_ID);
rec.setDx1(x);
rec.setDy1(y);
rec.setDx2(w);
rec.setDy2(h);
} else {
- EscherClientAnchorRecord rec = (EscherClientAnchorRecord)getEscherChild(EscherClientAnchorRecord.RECORD_ID);
+ EscherClientAnchorRecord rec = getEscherChild(EscherClientAnchorRecord.RECORD_ID);
rec.setCol1((short)x);
rec.setFlag((short)y);
rec.setDx1((short)w);
PPDrawing ppdrawing = getPPDrawing();
EscherContainerRecord dgContainer = ppdrawing.getDgContainer();
- EscherContainerRecord spgr = (EscherContainerRecord) HSLFShape.getEscherChild(dgContainer, EscherContainerRecord.SPGR_CONTAINER);
+ EscherContainerRecord spgr = HSLFShape.getEscherChild(dgContainer, EscherContainerRecord.SPGR_CONTAINER);
spgr.addChildRecord(shape.getSpContainer());
shape.setSheet(this);
//initialize drawing group id
EscherDggRecord dgg = getSlideShow().getDocumentRecord().getPPDrawingGroup().getEscherDggRecord();
EscherContainerRecord dgContainer = getSheetContainer().getPPDrawing().getDgContainer();
- EscherDgRecord dg = (EscherDgRecord) HSLFShape.getEscherChild(dgContainer, EscherDgRecord.RECORD_ID);
+ EscherDgRecord dg = HSLFShape.getEscherChild(dgContainer, EscherDgRecord.RECORD_ID);
int dgId = dgg.getMaxDrawingGroupId() + 1;
dg.setOptions((short)(dgId << 4));
dgg.setDrawingsSaved(dgg.getDrawingsSaved() + 1);
EscherContainerRecord bstore;
EscherContainerRecord dggContainer = _documentRecord.getPPDrawingGroup().getDggContainer();
- bstore = (EscherContainerRecord) HSLFShape.getEscherChild(dggContainer,
+ bstore = HSLFShape.getEscherChild(dggContainer,
EscherContainerRecord.BSTORE_CONTAINER);
if (bstore == null) {
bstore = new EscherContainerRecord();
RecordContainer _txtbox = headerAtom.getParentRecord();
if (_txtbox instanceof EscherTextboxWrapper) {
try {
- ((EscherTextboxWrapper) _txtbox).writeOut(null);
+ _txtbox.writeOut(null);
} catch (IOException e) {
throw new HSLFException("failed dummy write", e);
}
public boolean has7BitEncodingStrings() {
for(Chunk c : mainChunks.getChunks()) {
if(c instanceof StringChunk) {
- if( ((StringChunk)c).getType() == Types.ASCII_STRING ) {
+ if( c.getType() == Types.ASCII_STRING ) {
return true;
}
}
if (nameIdChunks!=null) {
for(Chunk c : nameIdChunks.getChunks()) {
if(c instanceof StringChunk) {
- if( ((StringChunk)c).getType() == Types.ASCII_STRING ) {
+ if( c.getType() == Types.ASCII_STRING ) {
return true;
}
}
for(RecipientChunks rc : recipientChunks) {
for(Chunk c : rc.getAll()) {
if(c instanceof StringChunk) {
- if( ((StringChunk)c).getType() == Types.ASCII_STRING ) {
+ if( c.getType() == Types.ASCII_STRING ) {
return true;
}
}
this.bkMode = other.bkMode;
this.polyfillMode = other.polyfillMode;
if (other.region instanceof Rectangle2D) {
- this.region = ((Rectangle2D)other.region).getBounds2D();
+ this.region = other.region.getBounds2D();
} else if (other.region instanceof Area) {
this.region = new Area(other.region);
}
}
public byte[] getRawBytes() {
- return ((CharSequence) _buf).toString().getBytes(
+ return _buf.toString().getBytes(
Charset.forName(_usesUnicode ? "UTF-16LE" : "Cp1252")
);
}
break;
case 0x3F:
// [MS-DOC], v20140721, 2.6.4, sprmSNFtn
- newSEP.setNFtn((int) sprm.getOperand());
+ newSEP.setNFtn(sprm.getOperand());
break;
case 0x40:
// [MS-DOC], v20140721, 2.6.4, sprmSNFtnRef
- newSEP.setNfcFtnRef((int) sprm.getOperand());
+ newSEP.setNfcFtnRef(sprm.getOperand());
break;
case 0x41:
// [MS-DOC], v20140721, 2.6.4, sprmSNEdn
- newSEP.setNEdn((int) sprm.getOperand());
+ newSEP.setNEdn(sprm.getOperand());
break;
case 0x42:
// [MS-DOC], v20140721, 2.6.4, sprmSNEdnRef
- newSEP.setNfcEdnRef((int) sprm.getOperand());
+ newSEP.setNfcEdnRef(sprm.getOperand());
break;
default:
logger.log(POILogger.INFO, "Unsupported Sprm operation: " + operation + " (" + HexDump.byteToHex(operation) + ")");
public void bug60294() throws IOException {
HSLFSlideShow ppt = open("60294.ppt");
List<HSLFShape> shList = ppt.getSlides().get(0).getShapes();
- assertEquals(ShapeType.NOT_PRIMITIVE, ((HSLFAutoShape)shList.get(2)).getShapeType());
+ assertEquals(ShapeType.NOT_PRIMITIVE, shList.get(2).getShapeType());
ppt.close();
}
}
EscherOptRecord officeArtFOPT = escherContainerRecord
.getChildById( (short) 0xF00B );
- EscherComplexProperty gtextUNICODE = (EscherComplexProperty) officeArtFOPT
+ EscherComplexProperty gtextUNICODE = officeArtFOPT
.lookup( 0x00c0 );
String text = StringUtil.getFromUnicodeLE(gtextUNICODE.getComplexData());
doc.write(baos);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- ((HSSFWorkbook)doc).close();
+ doc.close();
doc = new HSSFWorkbook(bais);
assertNotNull(doc.getSummaryInformation());
assertNotNull(doc.getDocumentSummaryInformation());
- ((HSSFWorkbook)doc).close();
+ doc.close();
}
@Test
ByteArrayOutputStream baos = new ByteArrayOutputStream();
doc.write(baos);
- ((HSSFWorkbook)doc).close();
+ doc.close();
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
doc = new HSSFWorkbook(bais);
baos = new ByteArrayOutputStream();
doc.write(baos);
- ((HSSFWorkbook)doc).close();
+ doc.close();
bais = new ByteArrayInputStream(baos.toByteArray());
doc = new HSSFWorkbook(bais);
assertEquals("POI Testing", doc.getSummaryInformation().getAuthor());
assertEquals("ASF", doc.getDocumentSummaryInformation().getCompany());
- ((HSSFWorkbook)doc).close();
+ doc.close();
}
}
* @return parsed token array already confirmed not <code>null</code>
*/
/* package */ static Ptg[] parseFormula(String formula) {
- Ptg[] result = HSSFFormulaParser.parse(formula, (HSSFWorkbook)null);
+ Ptg[] result = HSSFFormulaParser.parse(formula, null);
assertNotNull("Ptg array should not be null", result);
return result;
}
private static String toFormulaString(Ptg[] ptgs) {
- return HSSFFormulaParser.toFormulaString((HSSFWorkbook)null, ptgs);
+ return HSSFFormulaParser.toFormulaString(null, ptgs);
}
@Test
MemFuncPtg mf = (MemFuncPtg)ptgs[0];
assertEquals(57, mf.getLenRefSubexpression());
- assertEquals("D4:E5", ((AreaPtgBase)ptgs[7]).toFormulaString());
+ assertEquals("D4:E5", ptgs[7].toFormulaString());
assertTrue(((AttrPtg)ptgs[16]).isSum());
ptgs = parseFormula("SUM(A1:B2:C3:D4)");
Ptg[] ptgs;
try {
ptgs = HSSFFormulaParser.parse(leadingZeroCellRef, wb);
- assertEquals("B1", ((RefPtg) ptgs[0]).toFormulaString());
+ assertEquals("B1", ptgs[0].toFormulaString());
} catch (FormulaParseException e) {
confirmParseException(e, "Specified named range '"
+ leadingZeroCellRef + "' does not exist in the current workbook.");
public final class TestOperandClassTransformer extends TestCase {
private static Ptg[] parseFormula(String formula) {
- Ptg[] result = HSSFFormulaParser.parse(formula, (HSSFWorkbook)null);
+ Ptg[] result = HSSFFormulaParser.parse(formula, null);
assertNotNull("Ptg array should not be null", result);
return result;
}
assertEquals(RefPtg.class, ptg.getClass());
assertEquals(0, ((RefPtg)ptg).getRow());
assertEquals(0, ((RefPtg)ptg).getColumn());
- assertEquals(rv, ((RefPtg)ptg).getRVAType());
+ assertEquals(rv, ptg.getRVAType());
}
}
@Test
public void defaultShapeType() {
- HSSFComment comment = new HSSFComment((HSSFShape)null, new HSSFClientAnchor());
+ HSSFComment comment = new HSSFComment(null, new HSSFClientAnchor());
assertEquals(HSSFSimpleShape.OBJECT_TYPE_COMMENT, comment.getShapeType());
}
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("SimpleWithImages.xls");
@SuppressWarnings("unchecked") // TODO - add getFormat() to interface PictureData and genericise wb.getAllPictures()
- List<HSSFPictureData> lst = (List<HSSFPictureData>)(List<?>)wb.getAllPictures();
+ List<HSSFPictureData> lst = wb.getAllPictures();
//assertEquals(2, lst.size());
for (final HSSFPictureData pict : lst) {
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("53446.xls");
@SuppressWarnings("unchecked")
- List<HSSFPictureData> lst = (List<HSSFPictureData>)(List<?>)wb.getAllPictures();
+ List<HSSFPictureData> lst = wb.getAllPictures();
assertEquals(1, lst.size());
HSSFPictureData pict = lst.get(0);
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("SheetWithDrawing.xls");
@SuppressWarnings("unchecked") // TODO - add getFormat() to interface PictureData and genericise wb.getAllPictures()
- List<HSSFPictureData> lst = (List<HSSFPictureData>)(List<?>)wb.getAllPictures();
+ List<HSSFPictureData> lst = wb.getAllPictures();
for(HSSFPictureData pict : lst){
assertNotNull(pict);
}