poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1569984 - in /poi: site/src/documentation/content/xdocs/ trunk/src/scratchpad/src/org/apache/poi/hslf/record/ trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/ trunk/test-data/slideshow/
Date Wed, 19 Feb 2014 23:45:08 GMT
Author: kiwiwings
Date: Wed Feb 19 23:45:07 2014
New Revision: 1569984

URL: http://svn.apache.org/r1569984
Log:
Bug 55732 - PPT can't open, fails with "Couldn't instantiate .... StyleTextProp9Atom : java.lang.ArrayIndexOutOfBoundsException:
56"

Added:
    poi/trunk/test-data/slideshow/bug55732.ppt   (with props)
Modified:
    poi/site/src/documentation/content/xdocs/status.xml
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextProp9Atom.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java

Modified: poi/site/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/site/src/documentation/content/xdocs/status.xml?rev=1569984&r1=1569983&r2=1569984&view=diff
==============================================================================
--- poi/site/src/documentation/content/xdocs/status.xml (original)
+++ poi/site/src/documentation/content/xdocs/status.xml Wed Feb 19 23:45:07 2014
@@ -38,6 +38,7 @@
     </devs>
 
     <release version="3.11-beta1" date="2014-??-??">
+        <action dev="PD" type="fix" fixes-bug="55732">PPT can't open, fails with "Couldn't
instantiate ... StyleTextProp9Atom"</action>
         <action dev="PD" type="fix" fixes-bug="56138">HSPF code page strings can be
zero length</action>
         <action dev="PD" type="add" fixes-bug="53130">SXSSF Shared Strings option support</action>
         <action dev="PD" type="fix" fixes-bug="55902">Mixed fonts issue with Chinese
characters (unable to form images from ppt)</action>

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextProp9Atom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextProp9Atom.java?rev=1569984&r1=1569983&r2=1569984&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextProp9Atom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextProp9Atom.java Wed Feb
19 23:45:07 2014
@@ -27,11 +27,9 @@ import org.apache.poi.util.LittleEndian;
 
 /**
  * The atom record that specifies additional text formatting.
- *
- * @author Alex Nikiforov [mailto:anikif@gmail.com]
  */
 public final class StyleTextProp9Atom extends RecordAtom {
-	private final TextPFException9[] autoNumberSchemes;
+    private final TextPFException9[] autoNumberSchemes;
     /** Record header. */
     private byte[] header;
     /** Record data. */
@@ -50,7 +48,7 @@ public final class StyleTextProp9Atom ex
      */
     protected StyleTextProp9Atom(byte[] source, int start, int len) {
         // Get the header.
-    	final List<TextPFException9> schemes = new LinkedList<TextPFException9>();
+        final List<TextPFException9> schemes = new LinkedList<TextPFException9>();
         header = new byte[8];
         System.arraycopy(source,start, header,0,8);
         this.version  = LittleEndian.getShort(header, 0);
@@ -61,42 +59,51 @@ public final class StyleTextProp9Atom ex
         data = new byte[len-8];
         System.arraycopy(source, start+8, data, 0, len-8);
         for (int i = 0; i < data.length; ) {
-        	final TextPFException9 item = new TextPFException9(data, i);
-        	schemes.add(item);
-        	i += item.getRecordLength();
-        	//int textCfException9 = LittleEndian.getInt(data, i );
-        	//TODO analyze textCfException when have some test data
-        	i += 4;
-        	int textSiException = LittleEndian.getInt(data, i );
-        	i +=  + 4;//TextCFException9 + SIException
-        	if (0 != (textSiException & 0x40)) { 
-        		i += 2; //skip fBidi 
-        	}
-        	if (i >= data.length) {
-        		break;
-        	}
+            final TextPFException9 item = new TextPFException9(data, i);
+            schemes.add(item);
+            i += item.getRecordLength();
+            
+            if (i >= data.length) {
+                break;
+            }
+            int textCfException9 = LittleEndian.getInt(data, i );
+            i += 4;
+            //TODO analyze textCfException when have some test data
+            
+            if (i >= data.length) {
+                break;
+            }
+            int textSiException = LittleEndian.getInt(data, i );
+            i += 4;//TextCFException9 + SIException
+            
+            if (0 != (textSiException & 0x40)) { 
+                i += 2; //skip fBidi 
+            }
+            if (i >= data.length) {
+                break;
+            }
         }
         this.autoNumberSchemes = (TextPFException9[]) schemes.toArray(new TextPFException9[schemes.size()]);
     }
 
-	/**
+    /**
      * Gets the record type.
      * @return the record type.
      */
     public long getRecordType() { return this.recordId; }
 
     public short getVersion() {
-		return version;
-	}
+        return version;
+    }
 
-	public int getLength() {
-		return length;
-	}
-	public TextPFException9[] getAutoNumberTypes() {
-		return this.autoNumberSchemes;
-	}
+    public int getLength() {
+        return length;
+    }
+    public TextPFException9[] getAutoNumberTypes() {
+        return this.autoNumberSchemes;
+    }
 
-	/**
+    /**
      * Write the contents of the record back, so it can be written
      * to disk
      *
@@ -133,4 +140,4 @@ public final class StyleTextProp9Atom ex
         // Update the size (header bytes 5-8)
         LittleEndian.putInt(header, 4, data.length);
     }
-}
+}
\ No newline at end of file

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java?rev=1569984&r1=1569983&r2=1569984&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java Wed Feb
19 23:45:07 2014
@@ -21,6 +21,7 @@ import static org.junit.Assert.assertEqu
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
+import java.io.File;
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Date;
@@ -38,6 +39,7 @@ import org.apache.poi.hslf.HSLFTestDataS
 import org.apache.poi.hslf.exceptions.OldPowerPointFormatException;
 import org.apache.poi.hslf.model.Background;
 import org.apache.poi.hslf.model.Fill;
+import org.apache.poi.hslf.model.HeadersFooters;
 import org.apache.poi.hslf.model.MasterSheet;
 import org.apache.poi.hslf.model.Notes;
 import org.apache.poi.hslf.model.Picture;
@@ -484,4 +486,20 @@ public final class TestBugs {
         }
     }
 
+    @Test
+    public void bug55732() throws Exception {
+        File file = _slTests.getFile("bug55732.ppt");
+        
+        HSLFSlideShow ss = new HSLFSlideShow(file.getAbsolutePath());
+        SlideShow _show = new SlideShow(ss);
+        Slide[] _slides = _show.getSlides();
+
+        /* Iterate over slides and extract text */
+        for( Slide slide : _slides ) {
+            HeadersFooters hf = slide.getHeadersFooters();
+            boolean visible = hf.isHeaderVisible(); // exception happens here
+        }
+        assertTrue("No Exceptions while reading headers", true);
+    }
+    
 }

Added: poi/trunk/test-data/slideshow/bug55732.ppt
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/slideshow/bug55732.ppt?rev=1569984&view=auto
==============================================================================
Binary file - no diff available.

Propchange: poi/trunk/test-data/slideshow/bug55732.ppt
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message