aboutsummaryrefslogtreecommitdiffstats
path: root/src/scratchpad
diff options
context:
space:
mode:
authorMarius Volkhart <mariusvolkhart@apache.org>2021-03-09 19:26:31 +0000
committerMarius Volkhart <mariusvolkhart@apache.org>2021-03-09 19:26:31 +0000
commit7db6fa4ba175d04567d17c8ce1751936b4a2f026 (patch)
tree23b7e0da8b5c90c6f92dfd031c69c98de80cec92 /src/scratchpad
parentc05dbedbc56e5018f36b877d97b9c18d87da1279 (diff)
downloadpoi-7db6fa4ba175d04567d17c8ce1751936b4a2f026.tar.gz
poi-7db6fa4ba175d04567d17c8ce1751936b4a2f026.zip
Additional debug logging for unknown records in HSLF
Recently, while debugging app behavior on HSLF documents, I had to dig into the OOXML that Microsoft PowerPoint places into files saved in PPT format. Having information in the logs about when records were not parsed by POI was very helpful. The hex identifier was critical in being able to quickly search the [MS-PPT] spec for what type of record it was, and the integer identifier was helpful in quickly finding the Record type in RecordTypes.java. git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1887393 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/scratchpad')
-rw-r--r--src/scratchpad/src/org/apache/poi/hslf/record/Record.java7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/Record.java b/src/scratchpad/src/org/apache/poi/hslf/record/Record.java
index 2b06b4d7c3..be3bde7aab 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/record/Record.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/record/Record.java
@@ -25,6 +25,7 @@ import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.message.StringFormattedMessage;
import org.apache.poi.common.usermodel.GenericRecord;
import org.apache.poi.hslf.exceptions.CorruptPowerPointFileException;
import org.apache.poi.hslf.exceptions.HSLFException;
@@ -169,13 +170,17 @@ public abstract class Record implements GenericRecord
// A spot of reflection gets us the (byte[],int,int) constructor
// From there, we instanciate the class
// Any special record handling occurs once we have the class
- RecordConstructor c = RecordTypes.forTypeID((short)type).recordConstructor;
+ RecordTypes recordType = RecordTypes.forTypeID((short) type);
+ RecordConstructor c = recordType.recordConstructor;
if (c == null) {
// How odd. RecordTypes normally substitutes in
// a default handler class if it has heard of the record
// type but there's no support for it. Explicitly request
// that now
+ LOG.atDebug().log(() -> new StringFormattedMessage("Known but unhandled record type %d (0x%04x) at offset %d", type, type, start));
c = RecordTypes.UnknownRecordPlaceholder.recordConstructor;
+ } else if (recordType == RecordTypes.UnknownRecordPlaceholder) {
+ LOG.atDebug().log(() -> new StringFormattedMessage("Unknown placeholder type %d (0x%04x) at offset %d", type, type, start));
}
final Record toReturn;