You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ye...@apache.org on 2011/12/09 13:50:21 UTC
svn commit: r1212381 - in /poi/trunk/src:
documentation/content/xdocs/status.xml
scratchpad/src/org/apache/poi/hslf/model/Fill.java
scratchpad/src/org/apache/poi/hslf/model/Shape.java
scratchpad/testcases/org/apache/poi/hslf/model/TestBackground.java
Author: yegor
Date: Fri Dec 9 12:50:20 2011
New Revision: 1212381
URL: http://svn.apache.org/viewvc?rev=1212381&view=rev
Log:
Bugzilla 46288: fixed refcount of Fill pictures in HSLF
Modified:
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/Shape.java
poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestBackground.java
Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=1212381&r1=1212380&r2=1212381&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Fri Dec 9 12:50:20 2011
@@ -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>
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=1212381&r1=1212380&r2=1212381&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 Dec 9 12:50:20 2011
@@ -23,6 +23,7 @@ import org.apache.poi.hslf.usermodel.Pic
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.*;
@@ -117,6 +118,36 @@ public final class Fill {
}
/**
+ */
+ 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);
+ }
+ }
}
}
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=1212381&r1=1212380&r2=1212381&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 Dec 9 12:50:20 2011
@@ -342,7 +342,9 @@ public abstract class Shape {
* @param sh - owning shape
*/
protected void afterInsert(Sheet sh){
-
+ if(_fill != null) {
+ _fill.afterInsert(sh);
+ }
}
/**
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestBackground.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestBackground.java?rev=1212381&r1=1212380&r2=1212381&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestBackground.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestBackground.java Fri Dec 9 12:50:20 2011
@@ -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 extend
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 extend
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 extend
}
+ 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;
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org