From 6f98350f11fad1786db87647829c60817493417b Mon Sep 17 00:00:00 2001 From: Sergey Vladimirov Date: Mon, 4 Jul 2011 19:03:45 +0000 Subject: [PATCH] workaround for NPE caused by old Word format git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1142760 13f79535-47bb-0310-9956-ffa450edef68 --- src/scratchpad/src/org/apache/poi/hwpf/model/CHPX.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/CHPX.java b/src/scratchpad/src/org/apache/poi/hwpf/model/CHPX.java index b7c4db7e99..940f20438f 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/CHPX.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/CHPX.java @@ -57,11 +57,17 @@ public final class CHPX extends BytePropertyNode public CharacterProperties getCharacterProperties(StyleSheet ss, short istd) { - CharacterProperties baseStyle = ss.getCharacterStyle(istd); + CharacterProperties baseStyle; + if (ss == null) { + //old document format + baseStyle = new CharacterProperties(); + } else { + baseStyle = ss.getCharacterStyle(istd); + } CharacterProperties props = CharacterSprmUncompressor.uncompressCHP(baseStyle, getGrpprl(), 0); return props; } - + public String toString() { return "CHPX from " + getStart() + " to " + getEnd() + " (in bytes " + getStartBytes() + " to " + getEndBytes() + ")"; -- 2.39.5