poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cen...@apache.org
Subject svn commit: r1885092 - in /poi/trunk: src/java/org/apache/poi/ddf/ src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/ test-data/document/
Date Mon, 04 Jan 2021 05:51:24 GMT
Author: centic
Date: Mon Jan  4 05:51:24 2021
New Revision: 1885092

URL: http://svn.apache.org/viewvc?rev=1885092&view=rev
Log:
Bug 64132: Fix regression introduced by changing factories

We need to return EscherBlipRecord for all types in the defined range of recordId,
not UnknownEscherRecord.

Added:
    poi/trunk/test-data/document/64132.doc
Modified:
    poi/trunk/src/java/org/apache/poi/ddf/DefaultEscherRecordFactory.java
    poi/trunk/src/java/org/apache/poi/ddf/EscherBitmapBlip.java
    poi/trunk/src/java/org/apache/poi/ddf/EscherRecordTypes.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestBugs.java

Modified: poi/trunk/src/java/org/apache/poi/ddf/DefaultEscherRecordFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ddf/DefaultEscherRecordFactory.java?rev=1885092&r1=1885091&r2=1885092&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ddf/DefaultEscherRecordFactory.java (original)
+++ poi/trunk/src/java/org/apache/poi/ddf/DefaultEscherRecordFactory.java Mon Jan  4 05:51:24
2021
@@ -61,7 +61,7 @@ public class DefaultEscherRecordFactory
             return EscherContainerRecord::new;
         }
 
-        if (recordTypes.constructor != null) {
+        if (recordTypes.constructor != null && recordTypes != EscherRecordTypes.UNKNOWN)
{
             return recordTypes.constructor;
         }
 

Modified: poi/trunk/src/java/org/apache/poi/ddf/EscherBitmapBlip.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ddf/EscherBitmapBlip.java?rev=1885092&r1=1885091&r2=1885092&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ddf/EscherBitmapBlip.java (original)
+++ poi/trunk/src/java/org/apache/poi/ddf/EscherBitmapBlip.java Mon Jan  4 05:51:24 2021
@@ -74,7 +74,7 @@ public class EscherBitmapBlip extends Es
 
     @Override
     public int getRecordSize() {
-        return 8 + 16 + 1 + getPicturedata().length;
+        return 8 + 16 + 1 + (getPicturedata() == null ? 0 : getPicturedata().length);
     }
 
     /**

Modified: poi/trunk/src/java/org/apache/poi/ddf/EscherRecordTypes.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ddf/EscherRecordTypes.java?rev=1885092&r1=1885091&r2=1885092&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ddf/EscherRecordTypes.java (original)
+++ poi/trunk/src/java/org/apache/poi/ddf/EscherRecordTypes.java Mon Jan  4 05:51:24 2021
@@ -50,12 +50,12 @@ public enum EscherRecordTypes {
     CLSID(0xf016, null, null, null),
     CALLOUT_RULE(0xf017, null, null, null),
     BLIP_START(0xf018, "Blip", "msofbtBlip", null),
-    BLIP_EMF(0xf018 + 2, "BlipEmf", null, EscherMetafileBlip::new),
-    BLIP_WMF(0xf018 + 3, "BlipWmf", null, EscherMetafileBlip::new),
-    BLIP_PICT(0xf018 + 4, "BlipPict", null, EscherMetafileBlip::new),
-    BLIP_JPEG(0xf018 + 5, "BlipJpeg", null, EscherBitmapBlip::new),
-    BLIP_PNG(0xf018 + 6, "BlipPng", null, EscherBitmapBlip::new),
-    BLIP_DIB(0xf018 + 7, "BlipDib", null, EscherBitmapBlip::new),
+    BLIP_EMF(0xf018 + 2 /* 0xf01a */, "BlipEmf", null, EscherMetafileBlip::new),
+    BLIP_WMF(0xf018 + 3 /* 0xf01b */, "BlipWmf", null, EscherMetafileBlip::new),
+    BLIP_PICT(0xf018 + 4 /* 0xf01c */, "BlipPict", null, EscherMetafileBlip::new),
+    BLIP_JPEG(0xf018 + 5 /* 0xf01d */, "BlipJpeg", null, EscherBitmapBlip::new),
+    BLIP_PNG(0xf018 + 6 /* 0xf01e */, "BlipPng", null, EscherBitmapBlip::new),
+    BLIP_DIB(0xf018 + 7 /* 0xf01f */, "BlipDib", null, EscherBitmapBlip::new),
     BLIP_END(0xf117, "Blip", "msofbtBlip", null),
     REGROUP_ITEMS(0xf118, null, null, null),
     SELECTION(0xf119, null, null, null),

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=1885092&r1=1885091&r2=1885092&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 Mon Jan
 4 05:51:24 2021
@@ -892,4 +892,14 @@ public class TestBugs{
             assertNotNull(document);
         }
     }
+
+    @Test
+    public void test64132() throws IOException {
+        try(HWPFDocument doc = HWPFTestDataSamples.openSampleFile("64132.doc")) {
+            assertNotNull(doc);
+            PicturesTable picturesTable = doc.getPicturesTable();
+            List<Picture> pictures = picturesTable.getAllPictures();
+            assertNotNull(pictures);
+        }
+    }
 }

Added: poi/trunk/test-data/document/64132.doc
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/document/64132.doc?rev=1885092&view=auto
==============================================================================
Binary files poi/trunk/test-data/document/64132.doc (added) and poi/trunk/test-data/document/64132.doc
Mon Jan  4 05:51:24 2021 differ



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


Mime
View raw message