poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ser...@apache.org
Subject svn commit: r1195080 - in /poi/trunk: src/documentation/content/xdocs/ src/scratchpad/src/org/apache/poi/hwpf/model/ src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/ test-data/document/
Date Sun, 30 Oct 2011 00:33:45 GMT
Author: sergey
Date: Sun Oct 30 00:33:44 2011
New Revision: 1195080

URL: http://svn.apache.org/viewvc?rev=1195080&view=rev
Log:
Fix 47958 - ArrayIndexOutOfBoundsException from PicturesTable.getAllPictures() during Escher
tree walk
Fix 50936 - Exception parsing MS Word 8.0 file (as duplicate of 47958)

Added:
    poi/trunk/test-data/document/Bug50936_1.doc
      - copied unchanged from r1188233, poi/trunk/test-data/document/Bug50936.doc
    poi/trunk/test-data/document/Bug50936_2.doc   (with props)
    poi/trunk/test-data/document/Bug50936_3.doc   (with props)
Removed:
    poi/trunk/test-data/document/Bug50936.doc
Modified:
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PicturesTable.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestBugs.java

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=1195080&r1=1195079&r2=1195080&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Sun Oct 30 00:33:44 2011
@@ -34,6 +34,8 @@
 
     <changes>
         <release version="3.8-beta5" date="2011-??-??">
+           <action dev="poi-developers" type="fix">50936 - Exception parsing MS Word
8.0 file (as duplicate of 47958)</action>
+           <action dev="poi-developers" type="fix">47958 - ArrayIndexOutOfBoundsException
from PicturesTable.getAllPictures() during Escher tree walk</action>
            <action dev="poi-developers" type="fix">51944 - PAPFormattedDiskPage.getPAPX
- IndexOutOfBounds</action>
            <action dev="poi-developers" type="fix">52032 - HWPF - ArrayIndexOutofBoundsException
with no stack trace (broken after revision 1178063)</action>
            <action dev="poi-developers" type="add">support for converting pptx files
into images with a PPTX2PNG tool</action>

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PicturesTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PicturesTable.java?rev=1195080&r1=1195079&r2=1195080&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PicturesTable.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PicturesTable.java Sun Oct 30 00:33:44
2011
@@ -20,6 +20,10 @@ package org.apache.poi.hwpf.model;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.poi.util.POILogFactory;
+
+import org.apache.poi.util.POILogger;
+
 import org.apache.poi.ddf.DefaultEscherRecordFactory;
 import org.apache.poi.ddf.EscherBSERecord;
 import org.apache.poi.ddf.EscherBlipRecord;
@@ -52,6 +56,9 @@ import org.apache.poi.util.LittleEndian;
 @Internal
 public final class PicturesTable
 {
+    private static final POILogger logger = POILogFactory
+            .getLogger( PicturesTable.class );
+    
   static final int TYPE_IMAGE = 0x08;
   static final int TYPE_IMAGE_WORD2000 = 0x00;
   static final int TYPE_IMAGE_PASTED_FROM_CLIPBOARD = 0xA;
@@ -175,18 +182,32 @@ public final class PicturesTable
               {
                   pictures.add(new Picture(blip.getPicturedata()));
               }
-              else if (bse.getOffset() > 0)
-              {
-                  // Blip stored in delay stream, which in a word doc, is the main stream
-                  EscherRecordFactory recordFactory = new DefaultEscherRecordFactory();
-                  EscherRecord record = recordFactory.createRecord(_mainStream, bse.getOffset());
-
-                  if (record instanceof EscherBlipRecord) {
-                      record.fillFields(_mainStream, bse.getOffset(), recordFactory);
-                      blip = (EscherBlipRecord) record;
-                      pictures.add(new Picture(blip.getPicturedata()));
-                  }
-              }
+                else if ( bse.getOffset() > 0 )
+                {
+                    try
+                    {
+                        // Blip stored in delay stream, which in a word doc, is
+                        // the main stream
+                        EscherRecordFactory recordFactory = new DefaultEscherRecordFactory();
+                        EscherRecord record = recordFactory.createRecord(
+                                _mainStream, bse.getOffset() );
+
+                        if ( record instanceof EscherBlipRecord )
+                        {
+                            record.fillFields( _mainStream, bse.getOffset(),
+                                    recordFactory );
+                            blip = (EscherBlipRecord) record;
+                            pictures.add( new Picture( blip.getPicturedata() ) );
+                        }
+                    }
+                    catch ( Exception exc )
+                    {
+                        logger.log(
+                                POILogger.WARN,
+                                "Unable to load picture from BLIB record at offset #",
+                                Integer.valueOf( bse.getOffset() ), exc );
+                    }
+                }
           }
 
           // Recursive call.

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestBugs.java?rev=1195080&r1=1195079&r2=1195080&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestBugs.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestBugs.java Sun Oct
30 00:33:44 2011
@@ -463,23 +463,12 @@ public class TestBugs extends TestCase
     }
 
     /**
-     * [FAILING] Bug 47958 - Exception during Escher walk of pictures
+     * Bug 47958 - Exception during Escher walk of pictures
      */
     public void test47958()
     {
         HWPFDocument doc = HWPFTestDataSamples.openSampleFile( "Bug47958.doc" );
-        try
-        {
-            for ( Picture pic : doc.getPicturesTable().getAllPictures() )
-            {
-                System.out.println( pic.suggestFullFileName() );
-            }
-            fixed( "47958" );
-        }
-        catch ( Exception e )
-        {
-            // expected exception
-        }
+        doc.getPicturesTable().getAllPictures();
     }
 
     /**
@@ -513,11 +502,33 @@ public class TestBugs extends TestCase
     }
 
     /**
-     * Bug 50936 - HWPF fails to read a file
+     * Bug 50936 - Exception parsing MS Word 8.0 file
+     */
+    public void test50936_1()
+    {
+        HWPFDocument hwpfDocument = HWPFTestDataSamples
+                .openSampleFile( "Bug50936_1.doc" );
+        hwpfDocument.getPicturesTable().getAllPictures();
+    }
+
+    /**
+     * Bug 50936 - Exception parsing MS Word 8.0 file
+     */
+    public void test50936_2()
+    {
+        HWPFDocument hwpfDocument = HWPFTestDataSamples
+                .openSampleFile( "Bug50936_2.doc" );
+        hwpfDocument.getPicturesTable().getAllPictures();
+    }
+
+    /**
+     * Bug 50936 - Exception parsing MS Word 8.0 file
      */
-    public void test50936()
+    public void test50936_3()
     {
-        HWPFTestDataSamples.openSampleFile( "Bug50936.doc" );
+        HWPFDocument hwpfDocument = HWPFTestDataSamples
+                .openSampleFile( "Bug50936_3.doc" );
+        hwpfDocument.getPicturesTable().getAllPictures();
     }
 
     /**

Added: poi/trunk/test-data/document/Bug50936_2.doc
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/document/Bug50936_2.doc?rev=1195080&view=auto
==============================================================================
Binary file - no diff available.

Propchange: poi/trunk/test-data/document/Bug50936_2.doc
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: poi/trunk/test-data/document/Bug50936_3.doc
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/document/Bug50936_3.doc?rev=1195080&view=auto
==============================================================================
Binary file - no diff available.

Propchange: poi/trunk/test-data/document/Bug50936_3.doc
------------------------------------------------------------------------------
    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