]> source.dussan.org Git - poi.git/commitdiff
Don't blindly cast children to FontEntityAtom
authorNick Burch <nick@apache.org>
Tue, 9 May 2006 10:47:22 +0000 (10:47 +0000)
committerNick Burch <nick@apache.org>
Tue, 9 May 2006 10:47:22 +0000 (10:47 +0000)
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@405381 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/src/org/apache/poi/hslf/record/FontCollection.java

index d11ba429e4994d26b4b8d85d9e4b5259def879d0..dbc93d404a38db017168da8550b9dba25b5f2a66 100644 (file)
@@ -38,13 +38,17 @@ public class FontCollection extends RecordContainer {
                System.arraycopy(source,start,_header,0,8);
 
                _children = Record.findChildRecords(source,start+8,len-8);
-        // Save font names into <code>List</code>
-        fonts = new ArrayList();
-        for (int i = 0; i < _children.length; i++){
-            FontEntityAtom atom = (FontEntityAtom)_children[i];
-            fonts.add(atom.getFontName());
-        }
 
+               // Save font names into <code>List</code>
+               fonts = new ArrayList();
+               for (int i = 0; i < _children.length; i++){
+                       if(_children[i] instanceof FontEntityAtom) {
+                   FontEntityAtom atom = (FontEntityAtom)_children[i];
+                   fonts.add(atom.getFontName());
+                       } else {
+                               System.err.println("Warning: FontCollection child wasn't a FontEntityAtom, was " + _children[i]);
+                       }
+               }
        }
 
        /**