From 56d1f1b97afbdb07dc0a619cda3206b49f7a0340 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Tue, 25 Jun 2013 15:40:05 +0000 Subject: [PATCH] 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 --- .../src/org/apache/poi/hslf/model/Sheet.java | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/Sheet.java b/src/scratchpad/src/org/apache/poi/hslf/model/Sheet.java index 6fef2cc8e..46670ff36 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/Sheet.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/Sheet.java @@ -175,30 +175,35 @@ public abstract class Sheet { protected static void findTextRuns(final Record[] records, final List found, final StyleTextProp9Atom styleTextProp9Atom) { for (int i = 0, slwtIndex=0; i < (records.length - 1); i++) { if (records[i] instanceof TextHeaderAtom) { - TextRun trun = null; TextHeaderAtom tha = (TextHeaderAtom) records[i]; StyleTextPropAtom stpa = null; - - // Look for a subsequent StyleTextPropAtom + TextRun trun = null; + Record next = null; + + // 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 (records[i + 2] instanceof StyleTextPropAtom) { - stpa = (StyleTextPropAtom) records[i + 2]; + next = records[i+2]; + if (next instanceof StyleTextPropAtom) { + stpa = (StyleTextPropAtom)next; } } // See what follows the TextHeaderAtom - if (records[i + 1] instanceof TextCharsAtom) { - TextCharsAtom tca = (TextCharsAtom) records[i + 1]; + next = records[i+1]; + if (next instanceof TextCharsAtom) { + TextCharsAtom tca = (TextCharsAtom)next; trun = new TextRun(tha, tca, stpa); - } else if (records[i + 1] instanceof TextBytesAtom) { - TextBytesAtom tba = (TextBytesAtom) records[i + 1]; + } else if (next instanceof TextBytesAtom) { + TextBytesAtom tba = (TextBytesAtom)next; trun = new TextRun(tha, tba, stpa); - } else if (records[i + 1].getRecordType() == 4001l) { - stpa = (StyleTextPropAtom) records[i + 1]; - } else if (records[i + 1].getRecordType() == 4010l) { - // TextSpecInfoAtom - Safe to ignore + } else if (next instanceof StyleTextPropAtom) { + stpa = (StyleTextPropAtom)next; + } else if (next.getRecordType() == (long)RecordTypes.TextSpecInfoAtom.typeID || + next.getRecordType() == (long)RecordTypes.BaseTextPropAtom.typeID) { + // Safe to ignore these ones } 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) {