diff options
author | Yegor Kozlov <yegor@apache.org> | 2008-01-25 19:37:22 +0000 |
---|---|---|
committer | Yegor Kozlov <yegor@apache.org> | 2008-01-25 19:37:22 +0000 |
commit | 98530c4c2c7ccbe8ee7febb7198fe763a52393f7 (patch) | |
tree | 578feef4736c83b253f778f4fb23f1c1456b04d1 | |
parent | 62a38a7ce7a0819f0954ea0f0091cf9980e319f3 (diff) | |
download | poi-98530c4c2c7ccbe8ee7febb7198fe763a52393f7.tar.gz poi-98530c4c2c7ccbe8ee7febb7198fe763a52393f7.zip |
fix bug #44296: HSLF Not Extracting Slide Background Image
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@615315 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | src/documentation/content/xdocs/changes.xml | 1 | ||||
-rw-r--r-- | src/documentation/content/xdocs/status.xml | 1 | ||||
-rw-r--r-- | src/scratchpad/src/org/apache/poi/hslf/model/Fill.java | 20 | ||||
-rw-r--r-- | src/scratchpad/src/org/apache/poi/hslf/model/Picture.java | 2 | ||||
-rw-r--r-- | src/scratchpad/src/org/apache/poi/hslf/model/Shape.java | 2 | ||||
-rw-r--r-- | src/scratchpad/src/org/apache/poi/hslf/model/Slide.java | 7 | ||||
-rwxr-xr-x | src/scratchpad/testcases/org/apache/poi/hslf/data/44296.ppt | bin | 0 -> 116224 bytes | |||
-rw-r--r-- | src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java | 20 |
8 files changed, 45 insertions, 8 deletions
diff --git a/src/documentation/content/xdocs/changes.xml b/src/documentation/content/xdocs/changes.xml index b1d8184e75..d5f6e9c531 100644 --- a/src/documentation/content/xdocs/changes.xml +++ b/src/documentation/content/xdocs/changes.xml @@ -36,6 +36,7 @@ <!-- Don't forget to update status.xml too! --> <release version="3.0.2-FINAL" date="2008-??-??"> + <action dev="POI-DEVELOPERS" type="fix">44296 - Fix for reading slide background images</action> <action dev="POI-DEVELOPERS" type="fix">44293 - Avoid swapping AreaPtgs from relative to absolute</action> <action dev="POI-DEVELOPERS" type="fix">44292 - Correctly process the last paragraph in a word file</action> <action dev="POI-DEVELOPERS" type="fix">44254 - Avoid some unread byte warnings, and properly understand DVALRecord</action> diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 8221954c09..69190f915f 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -33,6 +33,7 @@ <!-- Don't forget to update changes.xml too! --> <changes> <release version="3.0.2-FINAL" date="2008-??-??"> + <action dev="POI-DEVELOPERS" type="fix">44296 - Fix for reading slide background images</action> <action dev="POI-DEVELOPERS" type="fix">44293 - Avoid swapping AreaPtgs from relative to absolute</action> <action dev="POI-DEVELOPERS" type="fix">44292 - Correctly process the last paragraph in a word file</action> <action dev="POI-DEVELOPERS" type="fix">44254 - Avoid some unread byte warnings, and properly understand DVALRecord</action> diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/Fill.java b/src/scratchpad/src/org/apache/poi/hslf/model/Fill.java index 7eae4edc4c..f9cc43a7ea 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/Fill.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/Fill.java @@ -23,6 +23,8 @@ import org.apache.poi.hslf.record.*; import org.apache.poi.hslf.usermodel.PictureData; import org.apache.poi.hslf.usermodel.SlideShow; import org.apache.poi.hslf.exceptions.HSLFException; +import org.apache.poi.util.POILogger; +import org.apache.poi.util.POILogFactory; import java.awt.*; import java.util.*; @@ -33,6 +35,9 @@ import java.util.*; * @author Yegor Kozlov */ public class Fill { + // For logging + protected POILogger logger = POILogFactory.getLogger(this.getClass()); + /** * Fill with a solid color */ @@ -208,15 +213,18 @@ public class Fill { java.util.List lst = bstore.getChildRecords(); int idx = p.getPropertyValue(); - EscherBSERecord bse = (EscherBSERecord)lst.get(idx); - for ( int i = 0; i < pict.length; i++ ) { - if (pict[i].getOffset() == bse.getOffset()){ - return pict[i]; + if (idx == 0){ + logger.log(POILogger.ERROR, "no reference to picture data found "); + } else { + EscherBSERecord bse = (EscherBSERecord)lst.get(idx - 1); + for ( int i = 0; i < pict.length; i++ ) { + if (pict[i].getOffset() == bse.getOffset()){ + return pict[i]; + } } } - throw new HSLFException("Picture data not found: \n" + - " bse: " + bse + " at " + bse.getOffset() ); + return null; } /** diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/Picture.java b/src/scratchpad/src/org/apache/poi/hslf/model/Picture.java index 0740e23bce..90efd5f3ee 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/Picture.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/Picture.java @@ -109,7 +109,7 @@ public class Picture extends SimpleShape { */ public int getPictureIndex(){ EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID); - EscherSimpleProperty prop = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.BLIP__BLIPTODISPLAY + 0x4000); + EscherSimpleProperty prop = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.BLIP__BLIPTODISPLAY); return prop == null ? 0 : prop.getPropertyValue(); } diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/Shape.java b/src/scratchpad/src/org/apache/poi/hslf/model/Shape.java index 56d77764e9..5cff81a8d7 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/Shape.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/Shape.java @@ -227,7 +227,7 @@ public abstract class Shape { for ( Iterator iterator = opt.getEscherProperties().iterator(); iterator.hasNext(); ) { EscherProperty prop = (EscherProperty) iterator.next(); - if (prop.getId() == propId) + if (prop.getPropertyNumber() == propId) return prop; } return null; diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java b/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java index 201a069fc4..ea7201751d 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java @@ -262,4 +262,11 @@ public class Slide extends Sheet SlideAtom sa = getSlideRecord().getSlideAtom(); return sa.getFollowMasterBackground(); } + + public Background getBackground() { + if(getFollowMasterBackground()) + return getMasterSheet().getBackground(); + else + return super.getBackground(); + } } diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/data/44296.ppt b/src/scratchpad/testcases/org/apache/poi/hslf/data/44296.ppt Binary files differnew file mode 100755 index 0000000000..1e0529db1d --- /dev/null +++ b/src/scratchpad/testcases/org/apache/poi/hslf/data/44296.ppt diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java index 996a733ac9..f3f5f8e7ee 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java @@ -330,4 +330,24 @@ public class TestBugs extends TestCase { assertEquals(tr1[i].getText(), tr2[i].getText());
}
}
+
+ /**
+ * Bug 44296: HSLF Not Extracting Slide Background Image
+ */
+ public void test44296 () throws Exception {
+ FileInputStream is = new FileInputStream(new File(cwd, "44296.ppt"));
+ SlideShow ppt = new SlideShow(is);
+ is.close();
+
+ Slide slide = ppt.getSlides()[0];
+
+ Background b = slide.getBackground();
+ Fill f = b.getFill();
+ assertEquals(Fill.FILL_PICTURE, f.getFillType());
+
+ PictureData pict = f.getPictureData();
+ assertNotNull(pict);
+ assertEquals(Picture.JPEG, pict.getType());
+ }
+
}
|