]> source.dussan.org Git - poi.git/commitdiff
Fix work bug #42799
authorNick Burch <nick@apache.org>
Tue, 4 Dec 2007 12:33:24 +0000 (12:33 +0000)
committerNick Burch <nick@apache.org>
Tue, 4 Dec 2007 12:33:24 +0000 (12:33 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@600910 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/src/org/apache/poi/hwpf/model/ListTables.java

index cec20c91e650a1f2b8b3e4b798c32dee3b7268f1..4196566d9ad9a1faa0745be9a831bf30eb0af1e9 100644 (file)
@@ -19,6 +19,8 @@
 package org.apache.poi.hwpf.model;
 
 import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
 
 import org.apache.poi.hwpf.model.io.*;
 
@@ -37,6 +39,7 @@ public class ListTables
 {
   private static final int LIST_DATA_SIZE = 28;
   private static final int LIST_FORMAT_OVERRIDE_SIZE = 16;
+  private static POILogger log = POILogFactory.getLogger(ListTables.class);
 
   HashMap _listMap = new HashMap();
   ArrayList _overrideList = new ArrayList();
@@ -189,8 +192,13 @@ public class ListTables
   public ListLevel getLevel(int listID, int level)
   {
     ListData lst = (ListData)_listMap.get(new Integer(listID));
-    ListLevel lvl = lst.getLevels()[level];
-    return lvl;
+    if(level < lst.numLevels()) {
+       ListLevel lvl = lst.getLevels()[level];
+       return lvl;
+    } else {
+       log.log(POILogger.WARN, "Requested level " + level + " which was greater than the maximum defined (" + lst.numLevels() + ")"); 
+       return null;
+    }
   }
 
   public ListData getListData(int listID)