From f80d4eadfa8a914c021ea8b01e4d54e9406d8f6b Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Tue, 9 May 2006 10:47:22 +0000 Subject: [PATCH] Don't blindly cast children to FontEntityAtom git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@405381 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/poi/hslf/record/FontCollection.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/FontCollection.java b/src/scratchpad/src/org/apache/poi/hslf/record/FontCollection.java index d11ba429e49..dbc93d404a3 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/record/FontCollection.java +++ b/src/scratchpad/src/org/apache/poi/hslf/record/FontCollection.java @@ -38,13 +38,17 @@ protected FontCollection(byte[] source, int start, int len) { System.arraycopy(source,start,_header,0,8); _children = Record.findChildRecords(source,start+8,len-8); - // Save font names into List - fonts = new ArrayList(); - for (int i = 0; i < _children.length; i++){ - FontEntityAtom atom = (FontEntityAtom)_children[i]; - fonts.add(atom.getFontName()); - } + // Save font names into List + 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]); + } + } } /**