<!-- 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>
<!-- 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>
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.*;
* @author Yegor Kozlov
*/
public class Fill {
+ // For logging
+ protected POILogger logger = POILogFactory.getLogger(this.getClass());
+
/**
* Fill with a solid color
*/
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;
}
/**
*/
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();
}
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;
SlideAtom sa = getSlideRecord().getSlideAtom();
return sa.getFollowMasterBackground();
}
+
+ public Background getBackground() {
+ if(getFollowMasterBackground())
+ return getMasterSheet().getBackground();
+ else
+ return super.getBackground();
+ }
}
assertEquals(tr1[i].getText(), tr2[i].getText());\r
}\r
}\r
+\r
+ /**\r
+ * Bug 44296: HSLF Not Extracting Slide Background Image\r
+ */\r
+ public void test44296 () throws Exception {\r
+ FileInputStream is = new FileInputStream(new File(cwd, "44296.ppt"));\r
+ SlideShow ppt = new SlideShow(is);\r
+ is.close();\r
+\r
+ Slide slide = ppt.getSlides()[0];\r
+\r
+ Background b = slide.getBackground();\r
+ Fill f = b.getFill();\r
+ assertEquals(Fill.FILL_PICTURE, f.getFillType());\r
+\r
+ PictureData pict = f.getPictureData();\r
+ assertNotNull(pict);\r
+ assertEquals(Picture.JPEG, pict.getType());\r
+ }\r
+\r
}\r