Should have been submitted with c700203 (Refactoring row-blocks record reading logic in Sheet)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@700204 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
655f100a6c
commit
382ccf456f
@ -31,9 +31,9 @@ import org.apache.poi.hssf.record.Record;
|
||||
|
||||
|
||||
/**
|
||||
* ModelFactory creates workbook and sheet models based upon
|
||||
* ModelFactory creates workbook and sheet models based upon
|
||||
* events thrown by them there events from the EventRecordFactory.
|
||||
*
|
||||
*
|
||||
* @see org.apache.poi.hssf.eventmodel.EventRecordFactory
|
||||
* @author Andrew C. Oliver acoliver@apache.org
|
||||
*/
|
||||
@ -43,7 +43,7 @@ public class ModelFactory implements ERFListener
|
||||
List listeners;
|
||||
Model currentmodel;
|
||||
boolean lastEOF;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for ModelFactory. Does practically nothing.
|
||||
*/
|
||||
@ -52,15 +52,15 @@ public class ModelFactory implements ERFListener
|
||||
super();
|
||||
listeners = new ArrayList(1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* register a ModelFactoryListener so that it can receive
|
||||
* register a ModelFactoryListener so that it can receive
|
||||
* Models as they are created.
|
||||
*/
|
||||
public void registerListener(ModelFactoryListener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Start processing the Workbook stream into Model events.
|
||||
*/
|
||||
@ -75,31 +75,31 @@ public class ModelFactory implements ERFListener
|
||||
{
|
||||
if (rec.getSid() == BOFRecord.sid) {
|
||||
if (lastEOF != true) {
|
||||
throw new RuntimeException("Not yet handled embedded models");
|
||||
throw new RuntimeException("Not yet handled embedded models");
|
||||
} else {
|
||||
BOFRecord bof = (BOFRecord)rec;
|
||||
switch (bof.getType()) {
|
||||
case BOFRecord.TYPE_WORKBOOK:
|
||||
currentmodel = new Workbook();
|
||||
currentmodel = new Workbook();
|
||||
break;
|
||||
case BOFRecord.TYPE_WORKSHEET:
|
||||
currentmodel = new Sheet();
|
||||
currentmodel = Sheet.createSheet();
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("Unsupported model type "+bof.getType());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (rec.getSid() == EOFRecord.sid) {
|
||||
lastEOF = true;
|
||||
throwEvent(currentmodel);
|
||||
} else {
|
||||
lastEOF = false;
|
||||
lastEOF = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,10 @@ package org.apache.poi.hssf.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.poi.hssf.record.ArrayRecord;
|
||||
import org.apache.poi.hssf.record.BOFRecord;
|
||||
import org.apache.poi.hssf.record.BlankRecord;
|
||||
import org.apache.poi.hssf.record.BoolErrRecord;
|
||||
import org.apache.poi.hssf.record.CalcCountRecord;
|
||||
import org.apache.poi.hssf.record.CalcModeRecord;
|
||||
import org.apache.poi.hssf.record.DVALRecord;
|
||||
@ -30,22 +33,30 @@ import org.apache.poi.hssf.record.DimensionsRecord;
|
||||
import org.apache.poi.hssf.record.DrawingRecord;
|
||||
import org.apache.poi.hssf.record.DrawingSelectionRecord;
|
||||
import org.apache.poi.hssf.record.EOFRecord;
|
||||
import org.apache.poi.hssf.record.FormulaRecord;
|
||||
import org.apache.poi.hssf.record.GridsetRecord;
|
||||
import org.apache.poi.hssf.record.GutsRecord;
|
||||
import org.apache.poi.hssf.record.HyperlinkRecord;
|
||||
import org.apache.poi.hssf.record.IndexRecord;
|
||||
import org.apache.poi.hssf.record.IterationRecord;
|
||||
import org.apache.poi.hssf.record.LabelRecord;
|
||||
import org.apache.poi.hssf.record.LabelSSTRecord;
|
||||
import org.apache.poi.hssf.record.NumberRecord;
|
||||
import org.apache.poi.hssf.record.ObjRecord;
|
||||
import org.apache.poi.hssf.record.PaneRecord;
|
||||
import org.apache.poi.hssf.record.PrecisionRecord;
|
||||
import org.apache.poi.hssf.record.PrintGridlinesRecord;
|
||||
import org.apache.poi.hssf.record.PrintHeadersRecord;
|
||||
import org.apache.poi.hssf.record.RKRecord;
|
||||
import org.apache.poi.hssf.record.Record;
|
||||
import org.apache.poi.hssf.record.RecordBase;
|
||||
import org.apache.poi.hssf.record.RefModeRecord;
|
||||
import org.apache.poi.hssf.record.RowRecord;
|
||||
import org.apache.poi.hssf.record.SCLRecord;
|
||||
import org.apache.poi.hssf.record.SaveRecalcRecord;
|
||||
import org.apache.poi.hssf.record.SelectionRecord;
|
||||
import org.apache.poi.hssf.record.SharedFormulaRecord;
|
||||
import org.apache.poi.hssf.record.TableRecord;
|
||||
import org.apache.poi.hssf.record.TextObjectRecord;
|
||||
import org.apache.poi.hssf.record.UncalcedRecord;
|
||||
import org.apache.poi.hssf.record.UnknownRecord;
|
||||
@ -324,7 +335,7 @@ final class RecordOrderer {
|
||||
* It is assumed that at least one row or cell value record has been found prior to the current
|
||||
* record
|
||||
*/
|
||||
public static boolean isEndOfRowBlock(short sid) {
|
||||
public static boolean isEndOfRowBlock(int sid) {
|
||||
switch(sid) {
|
||||
case DrawingRecord.sid:
|
||||
case DrawingSelectionRecord.sid:
|
||||
@ -344,4 +355,29 @@ final class RecordOrderer {
|
||||
}
|
||||
return PageSettingsBlock.isComponentRecord(sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>true</code> if the specified record id normally appears in the row blocks section
|
||||
* of the sheet records
|
||||
*/
|
||||
public static boolean isRowBlockRecord(int sid) {
|
||||
switch (sid) {
|
||||
case RowRecord.sid:
|
||||
|
||||
case BlankRecord.sid:
|
||||
case BoolErrRecord.sid:
|
||||
case FormulaRecord.sid:
|
||||
case LabelRecord.sid:
|
||||
case LabelSSTRecord.sid:
|
||||
case NumberRecord.sid:
|
||||
case RKRecord.sid:
|
||||
|
||||
case ArrayRecord.sid:
|
||||
case SharedFormulaRecord.sid:
|
||||
case TableRecord.sid:
|
||||
return true;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -47,12 +47,12 @@ public final class FormulaRecordAggregate extends RecordAggregate implements Cel
|
||||
}
|
||||
boolean hasStringRec = stringRec != null;
|
||||
boolean hasCachedStringFlag = formulaRec.hasCachedResultString();
|
||||
if (hasStringRec != hasCachedStringFlag) {
|
||||
throw new RecordFormatException("String record was "
|
||||
+ (hasStringRec ? "": "not ") + " supplied but formula record flag is "
|
||||
+ (hasCachedStringFlag ? "" : "not ") + " set");
|
||||
}
|
||||
|
||||
if (hasStringRec != hasCachedStringFlag) {
|
||||
throw new RecordFormatException("String record was "
|
||||
+ (hasStringRec ? "": "not ") + " supplied but formula record flag is "
|
||||
+ (hasCachedStringFlag ? "" : "not ") + " set");
|
||||
}
|
||||
|
||||
if (formulaRec.isSharedFormula()) {
|
||||
svm.convertSharedFormulaRecord(formulaRec);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user