<changes>
<release version="3.8-beta5" date="2011-??-??">
+ <action dev="poi-developers" type="fix">46288 - fixed refcount of Fill pictures in HSLF </action>
<action dev="poi-developers" type="add">51961 - support compression of temp files in SXSSF </action>
<action dev="poi-developers" type="add">52268 - support cloning sheets with drawings in XSSF </action>
<action dev="poi-developers" type="add">52285 - Support XWPF smart tags text in Paragraphs</action>
import org.apache.poi.hslf.usermodel.SlideShow;
import org.apache.poi.util.POILogger;
import org.apache.poi.util.POILogFactory;
+import java.util.List;
import java.awt.*;
return prop == null ? FILL_SOLID : prop.getPropertyValue();
}
+ /**
+ */
+ protected void afterInsert(Sheet sh){
+ EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);
+ EscherSimpleProperty p = (EscherSimpleProperty)Shape.getEscherProperty(opt, EscherProperties.FILL__PATTERNTEXTURE);
+ if(p != null) {
+ int idx = p.getPropertyValue();
+ EscherBSERecord bse = getEscherBSERecord(idx);
+ bse.setRef(bse.getRef() + 1);
+ }
+ }
+
+ protected EscherBSERecord getEscherBSERecord(int idx){
+ Sheet sheet = shape.getSheet();
+ if(sheet == null) {
+ logger.log(POILogger.DEBUG, "Fill has not yet been assigned to a sheet");
+ return null;
+ }
+ SlideShow ppt = sheet.getSlideShow();
+ Document doc = ppt.getDocumentRecord();
+ EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
+ EscherContainerRecord bstore = (EscherContainerRecord)Shape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);
+ if(bstore == null) {
+ logger.log(POILogger.DEBUG, "EscherContainerRecord.BSTORE_CONTAINER was not found ");
+ return null;
+ }
+ List lst = bstore.getChildRecords();
+ return (EscherBSERecord)lst.get(idx-1);
+ }
+
/**
* Sets fill type.
* Must be one of the <code>FILL_*</code> constants defined in this class.
public void setPictureData(int idx){
EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);
Shape.setEscherProperty(opt, (short)(EscherProperties.FILL__PATTERNTEXTURE + 0x4000), idx);
+ if( idx != 0 ) {
+ if( shape.getSheet() != null ) {
+ EscherBSERecord bse = getEscherBSERecord(idx);
+ bse.setRef(bse.getRef() + 1);
+ }
+ }
}
}
* @param sh - owning shape
*/
protected void afterInsert(Sheet sh){
-
+ if(_fill != null) {
+ _fill.afterInsert(sh);
+ }
}
/**
import java.io.*;
import java.awt.*;
+import java.util.List;
+import org.apache.poi.ddf.*;
+import org.apache.poi.hslf.record.Document;
import org.apache.poi.hslf.usermodel.SlideShow;
import org.apache.poi.hslf.HSLFSlideShow;
import org.apache.poi.POIDataSamples;
+
/**
* Test <code>Fill</code> object.
*
fill = slides[0].getBackground().getFill();
assertEquals(Fill.FILL_PICTURE, fill.getFillType());
+ assertEquals(3, getFillPictureRefCount(slides[0].getBackground(), fill));
shape = slides[0].getShapes()[0];
assertEquals(Fill.FILL_SOLID, shape.getFill().getFillType());
fill = slides[2].getBackground().getFill();
assertEquals(Fill.FILL_TEXTURE, fill.getFillType());
+ assertEquals(3, getFillPictureRefCount(slides[2].getBackground(), fill));
shape = slides[2].getShapes()[0];
assertEquals(Fill.FILL_PICTURE, shape.getFill().getFillType());
+ assertEquals(1, getFillPictureRefCount(shape, fill));
fill = slides[3].getBackground().getFill();
assertEquals(Fill.FILL_SHADE_CENTER, fill.getFillType());
}
+ private int getFillPictureRefCount(Shape shape, Fill fill) {
+ EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);
+ EscherSimpleProperty p = (EscherSimpleProperty)Shape.getEscherProperty(opt, EscherProperties.FILL__PATTERNTEXTURE);
+ if(p != null) {
+ int idx = p.getPropertyValue();
+
+ Sheet sheet = shape.getSheet();
+ SlideShow ppt = sheet.getSlideShow();
+ Document doc = ppt.getDocumentRecord();
+ EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
+ EscherContainerRecord bstore = (EscherContainerRecord)Shape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);
+ List lst = bstore.getChildRecords();
+ return ((EscherBSERecord)lst.get(idx-1)).getRef();
+ }
+ return 0;
+ }
+
}