Add another record type to the "don't warn" list, and tidy up the code a little bit (see bug #54925)

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1496518 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2013-06-25 15:40:05 +00:00
parent a7bfec9271
commit 56d1f1b97a

View File

@ -175,30 +175,35 @@ public abstract class Sheet {
protected static void findTextRuns(final Record[] records, final List<TextRun> found, final StyleTextProp9Atom styleTextProp9Atom) { protected static void findTextRuns(final Record[] records, final List<TextRun> found, final StyleTextProp9Atom styleTextProp9Atom) {
for (int i = 0, slwtIndex=0; i < (records.length - 1); i++) { for (int i = 0, slwtIndex=0; i < (records.length - 1); i++) {
if (records[i] instanceof TextHeaderAtom) { if (records[i] instanceof TextHeaderAtom) {
TextRun trun = null;
TextHeaderAtom tha = (TextHeaderAtom) records[i]; TextHeaderAtom tha = (TextHeaderAtom) records[i];
StyleTextPropAtom stpa = null; StyleTextPropAtom stpa = null;
TextRun trun = null;
Record next = null;
// Look for a subsequent StyleTextPropAtom // Is there a StyleTextPropAtom after the Text Atom?
// TODO Do we need to check for text ones two away as well?
if (i < (records.length - 2)) { if (i < (records.length - 2)) {
if (records[i + 2] instanceof StyleTextPropAtom) { next = records[i+2];
stpa = (StyleTextPropAtom) records[i + 2]; if (next instanceof StyleTextPropAtom) {
stpa = (StyleTextPropAtom)next;
} }
} }
// See what follows the TextHeaderAtom // See what follows the TextHeaderAtom
if (records[i + 1] instanceof TextCharsAtom) { next = records[i+1];
TextCharsAtom tca = (TextCharsAtom) records[i + 1]; if (next instanceof TextCharsAtom) {
TextCharsAtom tca = (TextCharsAtom)next;
trun = new TextRun(tha, tca, stpa); trun = new TextRun(tha, tca, stpa);
} else if (records[i + 1] instanceof TextBytesAtom) { } else if (next instanceof TextBytesAtom) {
TextBytesAtom tba = (TextBytesAtom) records[i + 1]; TextBytesAtom tba = (TextBytesAtom)next;
trun = new TextRun(tha, tba, stpa); trun = new TextRun(tha, tba, stpa);
} else if (records[i + 1].getRecordType() == 4001l) { } else if (next instanceof StyleTextPropAtom) {
stpa = (StyleTextPropAtom) records[i + 1]; stpa = (StyleTextPropAtom)next;
} else if (records[i + 1].getRecordType() == 4010l) { } else if (next.getRecordType() == (long)RecordTypes.TextSpecInfoAtom.typeID ||
// TextSpecInfoAtom - Safe to ignore next.getRecordType() == (long)RecordTypes.BaseTextPropAtom.typeID) {
// Safe to ignore these ones
} else { } else {
logger.log(POILogger.ERROR, "Found a TextHeaderAtom not followed by a TextBytesAtom or TextCharsAtom: Followed by " + records[i + 1].getRecordType()); logger.log(POILogger.ERROR, "Found a TextHeaderAtom not followed by a TextBytesAtom or TextCharsAtom: Followed by " + next.getRecordType());
} }
if (trun != null) { if (trun != null) {