Author: yegor
Date: Fri Jan 25 11:37:22 2008
New Revision: 615315
URL: http://svn.apache.org/viewvc?rev=615315&view=rev
Log:
fix bug #44296: HSLF Not Extracting Slide Background Image
Added:
poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/data/44296.ppt
(with props)
Modified:
poi/trunk/src/documentation/content/xdocs/changes.xml
poi/trunk/src/documentation/content/xdocs/status.xml
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Fill.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Picture.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Shape.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java
poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java
Modified: poi/trunk/src/documentation/content/xdocs/changes.xml
URL:
http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/changes.xml?rev=615315&r1=615314&r2=615315&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/changes.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/changes.xml Fri Jan 25 11:37:22
2008
@@ -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>
Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL:
http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=615315&r1=615314&r2=615315&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Fri Jan 25 11:37:22
2008
@@ -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>
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Fill.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Fill.java?rev=615315&r1=615314&r2=615315&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Fill.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Fill.java Fri Jan 25
11:37:22 2008
@@ -23,6 +23,8 @@
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 @@
* @author Yegor Kozlov
*/
public class Fill {
+ // For logging
+ protected POILogger logger = POILogFactory.getLogger(this.getClass());
+
/**
* Fill with a solid color
*/
@@ -208,15 +213,18 @@
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;
}
/**
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Picture.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Picture.java?rev=615315&r1=615314&r2=615315&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Picture.java
(original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Picture.java Fri Jan
25 11:37:22 2008
@@ -109,7 +109,7 @@
*/
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();
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Shape.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Shape.java?rev=615315&r1=615314&r2=615315&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Shape.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Shape.java Fri Jan
25 11:37:22 2008
@@ -227,7 +227,7 @@
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;
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java?rev=615315&r1=615314&r2=615315&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java Fri Jan
25 11:37:22 2008
@@ -262,4 +262,11 @@
SlideAtom sa = getSlideRecord().getSlideAtom();
return sa.getFollowMasterBackground();
}
+
+ public Background getBackground() {
+ if(getFollowMasterBackground())
+ return getMasterSheet().getBackground();
+ else
+ return super.getBackground();
+ }
}
Added: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/data/44296.ppt
URL:
http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/data/44296.ppt?rev=615315&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/data/44296.ppt
------------------------------------------------------------------------------
svn:executable = *
Propchange:
poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/data/44296.ppt
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
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=615315&r1=615314&r2=615315&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
Fri Jan 25 11:37:22 2008
@@ -330,4 +330,24 @@
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());
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]