mirror of https://github.com/apache/poi.git
Bugzilla 46288: fixed refcount of Fill pictures in HSLF
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1212381 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3009b07746
commit
ad6cfe5ca1
|
@ -34,6 +34,7 @@
|
|||
|
||||
<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>
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.apache.poi.hslf.usermodel.PictureData;
|
|||
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.*;
|
||||
|
||||
|
@ -116,6 +117,36 @@ public final class Fill {
|
|||
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.
|
||||
|
@ -233,6 +264,12 @@ public final class Fill {
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -342,7 +342,9 @@ public abstract class Shape {
|
|||
* @param sh - owning shape
|
||||
*/
|
||||
protected void afterInsert(Sheet sh){
|
||||
|
||||
if(_fill != null) {
|
||||
_fill.afterInsert(sh);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,11 +21,15 @@ import junit.framework.TestCase;
|
|||
|
||||
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.
|
||||
*
|
||||
|
@ -163,6 +167,7 @@ public final class TestBackground extends TestCase {
|
|||
|
||||
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());
|
||||
|
||||
|
@ -173,8 +178,10 @@ public final class TestBackground extends TestCase {
|
|||
|
||||
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());
|
||||
|
@ -183,4 +190,21 @@ public final class TestBackground extends TestCase {
|
|||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue