diff options
author | Nick Burch <nick@apache.org> | 2008-01-09 23:21:35 +0000 |
---|---|---|
committer | Nick Burch <nick@apache.org> | 2008-01-09 23:21:35 +0000 |
commit | 7ad30758812963137fe648cb07eacabcddbaec56 (patch) | |
tree | 4d367ef4706707c3d9f0791ea9d8776dc48c5e8b /src/java/org/apache/poi/hssf/usermodel/HSSFPatriarch.java | |
parent | fbbd6523bad9a8d63050fbb87343e09c9c0127ed (diff) | |
download | poi-7ad30758812963137fe648cb07eacabcddbaec56.tar.gz poi-7ad30758812963137fe648cb07eacabcddbaec56.zip |
Make a start on processing shapes on a sheet out of a record. For now, doesn't actually manage to do this, but has much of the infrastructure that'll be needed. Includes ability to get an existing HSSFPatriarch for a sheet, if there are the required records, and for the HSSFPatriarch to be in a position to be given the shapes that make it up (but this isn't done yet)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@610608 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/poi/hssf/usermodel/HSSFPatriarch.java')
-rw-r--r-- | src/java/org/apache/poi/hssf/usermodel/HSSFPatriarch.java | 52 |
1 files changed, 50 insertions, 2 deletions
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFPatriarch.java b/src/java/org/apache/poi/hssf/usermodel/HSSFPatriarch.java index e383ed5586..3df804da76 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFPatriarch.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFPatriarch.java @@ -21,6 +21,13 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import org.apache.poi.ddf.EscherComplexProperty; +import org.apache.poi.ddf.EscherOptRecord; +import org.apache.poi.ddf.EscherProperty; +import org.apache.poi.hssf.record.EscherAggregate; +import org.apache.poi.util.LittleEndian; +import org.apache.poi.util.StringUtil; + /** * The patriarch is the toplevel container for shapes in a sheet. It does * little other than act as a container for other shapes and groups. @@ -38,12 +45,20 @@ public class HSSFPatriarch int y2 = 255; /** + * The EscherAggregate we have been bound to. + * (This will handle writing us out into records, + * and building up our shapes from the records) + */ + private EscherAggregate boundAggregate; + + /** * Creates the patriarch. * - * @param sheet the sheet this patriarch is stored in. + * @param sheet the sheet this patriarch is stored in. */ - HSSFPatriarch(HSSFSheet sheet) + HSSFPatriarch(HSSFSheet sheet, EscherAggregate boundAggregate) { + this.boundAggregate = boundAggregate; this.sheet = sheet; } @@ -173,6 +188,39 @@ public class HSSFPatriarch this.x2 = x2; this.y2 = y2; } + + /** + * Does this HSSFPatriarch contain a chart? + * (Technically a reference to a chart, since they + * get stored in a different block of records) + * FIXME - detect chart in all cases (only seems + * to work on some charts so far) + */ + public boolean containsChart() { + // TODO - support charts properly in usermodel + + // We're looking for a EscherOptRecord + EscherOptRecord optRecord = (EscherOptRecord) + boundAggregate.findFirstWithId(EscherOptRecord.RECORD_ID); + if(optRecord == null) { + // No opt record, can't have chart + return false; + } + + for(Iterator it = optRecord.getEscherProperties().iterator(); it.hasNext();) { + EscherProperty prop = (EscherProperty)it.next(); + if(prop.getPropertyNumber() == 896 && prop.isComplex()) { + EscherComplexProperty cp = (EscherComplexProperty)prop; + String str = StringUtil.getFromUnicodeLE(cp.getComplexData()); + System.err.println(str); + if(str.equals("Chart 1\0")) { + return true; + } + } + } + + return false; + } /** * The top left x coordinate of this group. |