import org.apache.poi.ddf.EscherBlipRecord;
import org.apache.poi.ddf.EscherRecord;
import org.apache.poi.hssf.OldExcelFormatException;
+import org.apache.poi.hssf.model.DrawingManager2;
import org.apache.poi.hssf.model.HSSFFormulaParser;
import org.apache.poi.hssf.model.InternalSheet;
import org.apache.poi.hssf.model.InternalWorkbook;
import org.apache.poi.hssf.model.RecordStream;
-import org.apache.poi.hssf.model.DrawingManager2;
import org.apache.poi.hssf.record.*;
import org.apache.poi.hssf.record.aggregates.RecordAggregate.RecordVisitor;
import org.apache.poi.hssf.record.common.UnicodeString;
import org.apache.poi.ss.formula.FormulaType;
import org.apache.poi.ss.formula.SheetNameFormatter;
import org.apache.poi.ss.formula.udf.AggregatingUDFFinder;
+import org.apache.poi.ss.formula.udf.IndexedUDFFinder;
import org.apache.poi.ss.formula.udf.UDFFinder;
import org.apache.poi.ss.usermodel.Row.MissingCellPolicy;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.util.Configurator;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
-import org.apache.poi.ss.formula.udf.IndexedUDFFinder;
/**
* this holds the HSSFFont objects attached to this workbook.
* We only create these from the low level records as required.
*/
- private Hashtable fonts;
+ private Hashtable<Short,HSSFFont> fonts;
/**
* holds whether or not to preserve other nodes in the POIFS. Used
workbook = InternalWorkbook.createWorkbook(records);
setPropertiesFromWorkbook(workbook);
int recOffset = workbook.getNumRecords();
- int sheetNum = 0;
// convert all LabelRecord records to LabelSSTRecord
convertLabelRecords(records, recOffset);
* @see org.apache.poi.hssf.record.SSTRecord
*/
- private void convertLabelRecords(List records, int offset)
+ private void convertLabelRecords(List<Record> records, int offset)
{
if (log.check( POILogger.DEBUG ))
log.log(POILogger.DEBUG, "convertLabelRecords called");
for (int k = offset; k < records.size(); k++)
{
- Record rec = ( Record ) records.get(k);
+ Record rec = records.get(k);
if (rec.getSid() == LabelRecord.sid)
{
return workbook.resolveNameXText(refIndex, definedNameIndex);
}
-
-
-
/**
* create an HSSFSheet for this HSSFWorkbook, adds it to the sheets and returns
* the high level representation. Use this to create new sheets.
public HSSFFont createFont()
{
- FontRecord font = workbook.createNewFont();
+ /*FontRecord font =*/ workbook.createNewFont();
short fontindex = (short) (getNumberOfFonts() - 1);
if (fontindex > 3)
* @return HSSFFont at the index
*/
public HSSFFont getFontAt(short idx) {
- if(fonts == null) fonts = new Hashtable();
+ if(fonts == null) fonts = new Hashtable<Short, HSSFFont>();
// So we don't confuse users, give them back
// the same object every time, but create
// them lazily
Short sIdx = Short.valueOf(idx);
if(fonts.containsKey(sIdx)) {
- return (HSSFFont)fonts.get(sIdx);
+ return fonts.get(sIdx);
}
FontRecord font = workbook.getFontRecordAt(idx);
* and that's not something you should normally do
*/
protected void resetFontCache() {
- fonts = new Hashtable();
+ fonts = new Hashtable<Short, HSSFFont>();
}
/**
*/
private static final class SheetRecordCollector implements RecordVisitor {
- private List _list;
+ private List<Record> _list;
private int _totalSize;
public SheetRecordCollector() {
_totalSize = 0;
- _list = new ArrayList(128);
+ _list = new ArrayList<Record>(128);
}
public int getTotalSize() {
return _totalSize;
public void visitRecord(Record r) {
_list.add(r);
_totalSize+=r.getRecordSize();
+
}
public int serialize(int offset, byte[] data) {
int result = 0;
int nRecs = _list.size();
for(int i=0; i<nRecs; i++) {
- Record rec = (Record)_list.get(i);
+ Record rec = _list.get(i);
result += rec.serialize(offset + result, data);
}
return result;
{
DrawingGroupRecord r = (DrawingGroupRecord) workbook.findFirstRecordBySid( DrawingGroupRecord.sid );
r.decode();
- List escherRecords = r.getEscherRecords();
+ List<EscherRecord> escherRecords = r.getEscherRecords();
PrintWriter w = new PrintWriter(System.out);
- for ( Iterator iterator = escherRecords.iterator(); iterator.hasNext(); )
+ for ( Iterator<EscherRecord> iterator = escherRecords.iterator(); iterator.hasNext(); )
{
- EscherRecord escherRecord = (EscherRecord) iterator.next();
+ EscherRecord escherRecord = iterator.next();
if (fat)
System.out.println(escherRecord.toString());
else
\r
package org.apache.poi.xssf.streaming;\r
\r
-import java.io.*;\r
+import java.io.File;\r
+import java.io.FileInputStream;\r
+import java.io.FileOutputStream;\r
+import java.io.IOException;\r
+import java.io.InputStream;\r
+import java.io.OutputStreamWriter;\r
+import java.io.Writer;\r
import java.util.zip.GZIPInputStream;\r
import java.util.zip.GZIPOutputStream;\r
\r
/**\r
* @return temp file to write sheet data\r
*/\r
- public File createTempFile()throws IOException {\r
+ @Override\r
+ public File createTempFile()throws IOException {\r
File fd = File.createTempFile("poi-sxssf-sheet-xml", ".gz");\r
return fd;\r
}\r
/**\r
* @return a wrapped instance of GZIPOutputStream\r
*/\r
- public Writer createWriter(File fd)throws IOException {\r
+ @Override\r
+ public Writer createWriter(File fd)throws IOException {\r
return new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(fd)));\r
}\r
\r
/**\r
* @return a GZIPInputStream stream to read the compressed temp file\r
*/\r
- public InputStream getWorksheetXMLInputStream() throws IOException {\r
+ @Override\r
+ public InputStream getWorksheetXMLInputStream() throws IOException {\r
File fd = getTempFile();\r
return new GZIPInputStream(new FileInputStream(fd));\r
}\r