git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1808508 13f79535-47bb-0310-9956-ffa450edef68tags/REL_4_0_0_FINAL
@@ -185,7 +185,7 @@ public class FormulaViewer | |||
private static String composeFormula(FormulaRecord record) | |||
{ | |||
return HSSFFormulaParser.toFormulaString((HSSFWorkbook)null, record.getParsedExpression()); | |||
return HSSFFormulaParser.toFormulaString(null, record.getParsedExpression()); | |||
} | |||
/** |
@@ -203,7 +203,7 @@ public class EventBasedExcelExtractor extends POIOLE2TextExtractor implements or | |||
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 |
@@ -2169,7 +2169,7 @@ public final class InternalWorkbook { | |||
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(); |
@@ -522,7 +522,7 @@ public final class EscherAggregate extends AbstractEscherHolderRecord { | |||
} | |||
for (NoteRecord noteRecord : tailRec.values()) { | |||
Record rec = (Record) noteRecord; | |||
Record rec = noteRecord; | |||
pos += rec.serialize(pos, data); | |||
} | |||
int bytesWritten = pos - offset; | |||
@@ -747,9 +747,9 @@ public final class EscherAggregate extends AbstractEscherHolderRecord { | |||
*/ | |||
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); | |||
} | |||
@@ -275,7 +275,7 @@ public final class ValueRecordsAggregate implements Iterable<CellValueRecordInte | |||
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); |
@@ -247,7 +247,7 @@ public class HSSFPicture extends HSSFSimpleShape implements Picture { | |||
* The filename of the embedded image | |||
*/ | |||
public String getFileName() { | |||
EscherComplexProperty propFile = (EscherComplexProperty) getOptRecord().lookup( | |||
EscherComplexProperty propFile = getOptRecord().lookup( | |||
EscherProperties.BLIP__BLIPFILENAME); | |||
return (null == propFile) | |||
? "" |
@@ -174,7 +174,7 @@ public final class HSSFRichTextString implements Comparable<HSSFRichTextString>, | |||
*/ | |||
public void applyFont(int startIndex, int endIndex, Font font) | |||
{ | |||
applyFont(startIndex, endIndex, ((HSSFFont) font).getIndex()); | |||
applyFont(startIndex, endIndex, font.getIndex()); | |||
} | |||
/** |
@@ -2130,7 +2130,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet { | |||
*/ | |||
@Override | |||
public void setDefaultColumnStyle(int column, CellStyle style) { | |||
_sheet.setDefaultColumnStyle(column, ((HSSFCellStyle) style).getIndex()); | |||
_sheet.setDefaultColumnStyle(column, style.getIndex()); | |||
} | |||
/** |
@@ -69,7 +69,7 @@ public class DirectoryNode | |||
final OPOIFSFileSystem filesystem, | |||
final DirectoryNode parent) | |||
{ | |||
this(property, parent, filesystem, (NPOIFSFileSystem)null); | |||
this(property, parent, filesystem, null); | |||
} | |||
/** | |||
@@ -84,7 +84,7 @@ public class DirectoryNode | |||
final NPOIFSFileSystem nfilesystem, | |||
final DirectoryNode parent) | |||
{ | |||
this(property, parent, (OPOIFSFileSystem)null, nfilesystem); | |||
this(property, parent, null, nfilesystem); | |||
} | |||
private DirectoryNode(final DirectoryProperty property, |
@@ -34,25 +34,19 @@ public class EntryUtils | |||
*/ | |||
@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 ); | |||
@@ -69,27 +63,12 @@ public class EntryUtils | |||
* 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 | |||
* |
@@ -927,7 +927,7 @@ public class NPOIFSFileSystem extends BlockStore | |||
{ | |||
if (preferArray()) | |||
{ | |||
return (( POIFSViewable ) getRoot()).getViewableArray(); | |||
return getRoot().getViewableArray(); | |||
} | |||
return new Object[ 0 ]; | |||
} | |||
@@ -944,7 +944,7 @@ public class NPOIFSFileSystem extends BlockStore | |||
{ | |||
if (!preferArray()) | |||
{ | |||
return (( POIFSViewable ) getRoot()).getViewableIterator(); | |||
return getRoot().getViewableIterator(); | |||
} | |||
return Collections.emptyList().iterator(); | |||
} | |||
@@ -959,7 +959,7 @@ public class NPOIFSFileSystem extends BlockStore | |||
public boolean preferArray() | |||
{ | |||
return (( POIFSViewable ) getRoot()).preferArray(); | |||
return getRoot().preferArray(); | |||
} | |||
/** |
@@ -494,7 +494,7 @@ public class OPOIFSFileSystem | |||
Property property = properties.next(); | |||
String name = property.getName(); | |||
DirectoryNode parent = (dir == null) | |||
? (( DirectoryNode ) getRoot()) | |||
? getRoot() | |||
: dir; | |||
if (property.isDirectory()) | |||
@@ -547,7 +547,7 @@ public class OPOIFSFileSystem | |||
{ | |||
if (preferArray()) | |||
{ | |||
return (( POIFSViewable ) getRoot()).getViewableArray(); | |||
return getRoot().getViewableArray(); | |||
} | |||
return new Object[ 0 ]; | |||
} | |||
@@ -564,7 +564,7 @@ public class OPOIFSFileSystem | |||
{ | |||
if (!preferArray()) | |||
{ | |||
return (( POIFSViewable ) getRoot()).getViewableIterator(); | |||
return getRoot().getViewableIterator(); | |||
} | |||
return Collections.emptyList().iterator(); | |||
} | |||
@@ -579,7 +579,7 @@ public class OPOIFSFileSystem | |||
public boolean preferArray() | |||
{ | |||
return (( POIFSViewable ) getRoot()).preferArray(); | |||
return getRoot().preferArray(); | |||
} | |||
/** |
@@ -209,14 +209,14 @@ public final class OperationEvaluationContext { | |||
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."); | |||
} |
@@ -191,7 +191,7 @@ public final class ArrayPtg extends Ptg { | |||
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()); |
@@ -258,7 +258,7 @@ public class DateUtil { | |||
* @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); | |||
} | |||
/** | |||
@@ -270,7 +270,7 @@ public class DateUtil { | |||
* @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); | |||
} | |||
/** |
@@ -489,7 +489,7 @@ implements SlideShow<XSLFShape,XSLFTextParagraph> { | |||
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 { |
@@ -1383,7 +1383,7 @@ public class SXSSFSheet implements Sheet | |||
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 + ")."); | |||
} |
@@ -521,7 +521,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook { | |||
@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); |
@@ -637,7 +637,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody { | |||
* 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; |
@@ -297,7 +297,7 @@ public class XWPFFootnote implements Iterable<XWPFParagraph>, IBody { | |||
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; |
@@ -400,7 +400,7 @@ public abstract class XWPFHeaderFooter extends POIXMLDocumentPart implements IBo | |||
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; |
@@ -95,7 +95,7 @@ public class XWPFSDTContent implements ISDTContent { | |||
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) { |
@@ -273,7 +273,7 @@ public class XWPFTableCell implements IBody, ICell { | |||
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; |
@@ -50,7 +50,7 @@ public class TestXSSFDrawing { | |||
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(); |
@@ -182,7 +182,7 @@ public final class TestXSSFFormulaParser { | |||
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(); | |||
} | |||
@@ -200,7 +200,7 @@ public final class TestXSSFFormulaParser { | |||
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"); | |||
@@ -209,7 +209,7 @@ public final class TestXSSFFormulaParser { | |||
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"); | |||
@@ -218,7 +218,7 @@ public final class TestXSSFFormulaParser { | |||
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"); | |||
@@ -243,7 +243,7 @@ public final class TestXSSFFormulaParser { | |||
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"); | |||
@@ -252,7 +252,7 @@ public final class TestXSSFFormulaParser { | |||
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"); | |||
@@ -261,7 +261,7 @@ public final class TestXSSFFormulaParser { | |||
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(); | |||
} |
@@ -714,7 +714,7 @@ public final class TestXSSFWorkbook extends BaseTestXWorkbook { | |||
// 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(); |
@@ -59,7 +59,7 @@ public class HSLFEscherRecordFactory extends DefaultEscherRecordFactory { | |||
escherRecord.setRecordId(recordId); | |||
escherRecord.setOptions(options); | |||
if (escherRecord instanceof EscherContainerRecord) { | |||
((EscherContainerRecord)escherRecord).fillFields(data, offset, this); | |||
escherRecord.fillFields(data, offset, this); | |||
} | |||
return escherRecord; |
@@ -262,7 +262,7 @@ public final class HSLFFill { | |||
// 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); |
@@ -360,7 +360,7 @@ public final class HSLFHyperlink implements Hyperlink<HSLFShape,HSLFTextParagrap | |||
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; |
@@ -192,13 +192,13 @@ public abstract class HSLFShape implements Shape<HSLFShape,HSLFTextParagraph> { | |||
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); |
@@ -199,7 +199,7 @@ public abstract class HSLFSheet implements HSLFShapeContainer, Sheet<HSLFShape,H | |||
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); |
@@ -162,7 +162,7 @@ public final class HSLFSlide extends HSLFSheet implements Slide<HSLFShape,HSLFTe | |||
//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); |
@@ -791,7 +791,7 @@ public final class HSLFSlideShow implements SlideShow<HSLFShape,HSLFTextParagrap | |||
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(); |
@@ -1094,7 +1094,7 @@ public final class HSLFTextParagraph implements TextParagraph<HSLFShape,HSLFText | |||
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); | |||
} |
@@ -487,7 +487,7 @@ public class MAPIMessage extends POIReadOnlyDocument { | |||
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; | |||
} | |||
} | |||
@@ -496,7 +496,7 @@ public class MAPIMessage extends POIReadOnlyDocument { | |||
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; | |||
} | |||
} | |||
@@ -506,7 +506,7 @@ public class MAPIMessage extends POIReadOnlyDocument { | |||
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; | |||
} | |||
} |
@@ -93,7 +93,7 @@ public class HwmfDrawProperties { | |||
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); | |||
} |
@@ -103,7 +103,7 @@ public class TextPiece extends PropertyNode<TextPiece> { | |||
} | |||
public byte[] getRawBytes() { | |||
return ((CharSequence) _buf).toString().getBytes( | |||
return _buf.toString().getBytes( | |||
Charset.forName(_usesUnicode ? "UTF-16LE" : "Cp1252") | |||
); | |||
} |
@@ -225,19 +225,19 @@ public final class SectionSprmUncompressor extends SprmUncompressor | |||
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) + ")"); |
@@ -1035,7 +1035,7 @@ public final class TestBugs { | |||
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(); | |||
} | |||
} |
@@ -46,7 +46,7 @@ public class TestOfficeDrawings extends TestCase | |||
EscherOptRecord officeArtFOPT = escherContainerRecord | |||
.getChildById( (short) 0xF00B ); | |||
EscherComplexProperty gtextUNICODE = (EscherComplexProperty) officeArtFOPT | |||
EscherComplexProperty gtextUNICODE = officeArtFOPT | |||
.lookup( 0x00c0 ); | |||
String text = StringUtil.getFromUnicodeLE(gtextUNICODE.getComplexData()); |
@@ -137,14 +137,14 @@ public final class TestPOIDocumentMain { | |||
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 | |||
@@ -159,7 +159,7 @@ public final class TestPOIDocumentMain { | |||
ByteArrayOutputStream baos = new ByteArrayOutputStream(); | |||
doc.write(baos); | |||
((HSSFWorkbook)doc).close(); | |||
doc.close(); | |||
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); | |||
doc = new HSSFWorkbook(bais); | |||
@@ -176,7 +176,7 @@ public final class TestPOIDocumentMain { | |||
baos = new ByteArrayOutputStream(); | |||
doc.write(baos); | |||
((HSSFWorkbook)doc).close(); | |||
doc.close(); | |||
bais = new ByteArrayInputStream(baos.toByteArray()); | |||
doc = new HSSFWorkbook(bais); | |||
@@ -194,6 +194,6 @@ public final class TestPOIDocumentMain { | |||
assertEquals("POI Testing", doc.getSummaryInformation().getAuthor()); | |||
assertEquals("ASF", doc.getDocumentSummaryInformation().getCompany()); | |||
((HSSFWorkbook)doc).close(); | |||
doc.close(); | |||
} | |||
} |
@@ -91,12 +91,12 @@ public final class TestFormulaParser { | |||
* @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 | |||
@@ -1456,7 +1456,7 @@ public final class TestFormulaParser { | |||
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)"); | |||
@@ -1567,7 +1567,7 @@ public final class TestFormulaParser { | |||
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."); |
@@ -33,7 +33,7 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook; | |||
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; | |||
} |
@@ -579,6 +579,6 @@ public final class TestFormulaEvaluatorBugs { | |||
assertEquals(RefPtg.class, ptg.getClass()); | |||
assertEquals(0, ((RefPtg)ptg).getRow()); | |||
assertEquals(0, ((RefPtg)ptg).getColumn()); | |||
assertEquals(rv, ((RefPtg)ptg).getRVAType()); | |||
assertEquals(rv, ptg.getRVAType()); | |||
} | |||
} |
@@ -57,7 +57,7 @@ public final class TestHSSFComment extends BaseTestCellComment { | |||
@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()); | |||
} | |||
@@ -42,7 +42,7 @@ public final class TestHSSFPictureData extends TestCase{ | |||
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) { | |||
@@ -74,7 +74,7 @@ public final class TestHSSFPictureData extends TestCase{ | |||
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); | |||
@@ -98,7 +98,7 @@ public final class TestHSSFPictureData extends TestCase{ | |||
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); | |||
} |