aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/poi/hssf/eventmodel
diff options
context:
space:
mode:
authorJason Height <jheight@apache.org>2005-08-18 07:06:44 +0000
committerJason Height <jheight@apache.org>2005-08-18 07:06:44 +0000
commitada69333b277a95ccfc608144b991cfd8d1a9d37 (patch)
tree824f57aa008b9d2e526fbffb23fcf40aa3e7e19a /src/java/org/apache/poi/hssf/eventmodel
parentc4fea20971ac2efc7766f88e546924dadaa7959a (diff)
downloadpoi-ada69333b277a95ccfc608144b991cfd8d1a9d37.tar.gz
poi-ada69333b277a95ccfc608144b991cfd8d1a9d37.zip
Major landing of the following changes:
1) Full implementation of UnicodeStrings 2) exposure of RichText strings to the usermodel 3) Modification to SSTRecord to support duplicates. Fixes a few bugs 4) RecordInputStream *smart* ?? handeling of continue records! Phew This took 6 months on and off to put together. Just happy to commit somethig Report any problems! git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353769 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/poi/hssf/eventmodel')
-rw-r--r--src/java/org/apache/poi/hssf/eventmodel/EventRecordFactory.java61
1 files changed, 11 insertions, 50 deletions
diff --git a/src/java/org/apache/poi/hssf/eventmodel/EventRecordFactory.java b/src/java/org/apache/poi/hssf/eventmodel/EventRecordFactory.java
index 50bafcf98c..c48dd8507b 100644
--- a/src/java/org/apache/poi/hssf/eventmodel/EventRecordFactory.java
+++ b/src/java/org/apache/poi/hssf/eventmodel/EventRecordFactory.java
@@ -83,6 +83,7 @@ import org.apache.poi.hssf.record.ProtectionRev4Record;
import org.apache.poi.hssf.record.RKRecord;
import org.apache.poi.hssf.record.Record;
import org.apache.poi.hssf.record.RecordFormatException;
+import org.apache.poi.hssf.record.RecordInputStream;
import org.apache.poi.hssf.record.RefModeRecord;
import org.apache.poi.hssf.record.RefreshAllRecord;
import org.apache.poi.hssf.record.RightMarginRecord;
@@ -262,22 +263,11 @@ public class EventRecordFactory
{
Record last_record = null;
- try
- {
- short rectype = 0;
-
- do
- {
- rectype = LittleEndian.readShort(in);
- if (rectype != 0)
- {
- short recsize = LittleEndian.readShort(in);
- byte[] data = new byte[ ( int ) recsize ];
-
- in.read(data);
- Record[] recs = createRecord(rectype, recsize,
- data); // handle MulRK records
+ RecordInputStream recStream = new RecordInputStream(in);
+ while (recStream.hasNextRecord()) {
+ recStream.nextRecord();
+ Record[] recs = createRecord(recStream); // handle MulRK records
if (recs.length > 1)
{
for (int k = 0; k < recs.length; k++)
@@ -288,8 +278,6 @@ public class EventRecordFactory
break;
}
}
- // records.add(
- // recs[ k ]); // these will be number records
last_record =
recs[ k ]; // do to keep the algorythm homogenous...you can't
} // actually continue a number record anyhow.
@@ -300,19 +288,6 @@ public class EventRecordFactory
if (record != null)
{
- if (rectype == ContinueRecord.sid &&
- ! (last_record instanceof ContinueRecord) && // include continuation records after
- ! (last_record instanceof UnknownRecord) ) // unknown records or previous continuation records
- {
- if (last_record == null)
- {
- throw new RecordFormatException(
- "First record is a ContinueRecord??");
- }
- last_record.processContinueRecord(data);
- }
- else
- {
if (last_record != null) {
if (throwRecordEvent(last_record) == false && abortable == true) {
last_record = null;
@@ -321,35 +296,21 @@ public class EventRecordFactory
}
last_record = record;
-
- //records.add(record);
}
}
}
- }
- }
- while (rectype != 0);
+
if (last_record != null) {
throwRecordEvent(last_record);
}
}
- catch (IOException e)
- {
- throw new RecordFormatException("Error reading bytes");
- }
-
- // Record[] retval = new Record[ records.size() ];
- // retval = ( Record [] ) records.toArray(retval);
-
- }
/**
* create a record, if there are MUL records than multiple records
* are returned digested into the non-mul form.
*/
- public static Record [] createRecord(short rectype, short size,
- byte [] data)
+ public static Record [] createRecord(RecordInputStream in)
{
Record retval = null;
Record[] realretval = null;
@@ -357,18 +318,18 @@ public class EventRecordFactory
try
{
Constructor constructor =
- ( Constructor ) recordsMap.get(new Short(rectype));
+ ( Constructor ) recordsMap.get(new Short(in.getSid()));
if (constructor != null)
{
retval = ( Record ) constructor.newInstance(new Object[]
{
- new Short(rectype), new Short(size), data
+ in
});
}
else
{
- retval = new UnknownRecord(rectype, size, data);
+ retval = new UnknownRecord(in);
}
}
catch (Exception introspectionException)
@@ -470,7 +431,7 @@ public class EventRecordFactory
sid = record.getField("sid").getShort(null);
constructor = record.getConstructor(new Class[]
{
- short.class, short.class, byte [].class
+ RecordInputStream.class
});
}
catch (Exception illegalArgumentException)