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 2012/08/10 13:30:44 UTC
svn commit: r1371663 [6/6] - in /poi/trunk: ./ src/java/org/apache/poi/ddf/
src/java/org/apache/poi/hssf/dev/ src/java/org/apache/poi/hssf/model/
src/java/org/apache/poi/hssf/record/
src/java/org/apache/poi/hssf/record/aggregates/ src/java/org/apache/p...
Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSimpleShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSimpleShape.java?rev=1371663&r1=1371662&r2=1371663&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSimpleShape.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSimpleShape.java Fri Aug 10 11:30:42 2012
@@ -17,25 +17,29 @@
package org.apache.poi.hssf.usermodel;
+import org.apache.poi.ddf.*;
+import org.apache.poi.hssf.record.*;
+import org.apache.poi.ss.usermodel.RichTextString;
+
/**
* Represents a simple shape such as a line, rectangle or oval.
*
* @author Glen Stampoultzis (glens at apache.org)
*/
-public class HSSFSimpleShape
- extends HSSFShape
+public class HSSFSimpleShape extends HSSFShape
{
// The commented out ones haven't been tested yet or aren't supported
// by HSSFSimpleShape.
- public final static short OBJECT_TYPE_LINE = 1;
- public final static short OBJECT_TYPE_RECTANGLE = 2;
- public final static short OBJECT_TYPE_OVAL = 3;
-// public final static short OBJECT_TYPE_ARC = 4;
-// public final static short OBJECT_TYPE_CHART = 5;
+ public final static short OBJECT_TYPE_LINE = HSSFShapeTypes.Line;
+ public final static short OBJECT_TYPE_RECTANGLE = HSSFShapeTypes.Rectangle;
+ public final static short OBJECT_TYPE_OVAL = HSSFShapeTypes.Ellipse;
+ public final static short OBJECT_TYPE_ARC = HSSFShapeTypes.Arc;
+ // public final static short OBJECT_TYPE_CHART = 5;
// public final static short OBJECT_TYPE_TEXT = 6;
// public final static short OBJECT_TYPE_BUTTON = 7;
- public final static short OBJECT_TYPE_PICTURE = 8;
+ public final static short OBJECT_TYPE_PICTURE = HSSFShapeTypes.PictureFrame;
+
// public final static short OBJECT_TYPE_POLYGON = 9;
// public final static short OBJECT_TYPE_CHECKBOX = 11;
// public final static short OBJECT_TYPE_OPTION_BUTTON = 12;
@@ -46,18 +50,157 @@ public class HSSFSimpleShape
// public final static short OBJECT_TYPE_SCROLL_BAR = 17;
// public final static short OBJECT_TYPE_LIST_BOX = 18;
// public final static short OBJECT_TYPE_GROUP_BOX = 19;
- public final static short OBJECT_TYPE_COMBO_BOX = 20;
- public final static short OBJECT_TYPE_COMMENT = 25;
-// public final static short OBJECT_TYPE_MICROSOFT_OFFICE_DRAWING = 30;
+ public final static short OBJECT_TYPE_COMBO_BOX = HSSFShapeTypes.HostControl;
+ public final static short OBJECT_TYPE_COMMENT = HSSFShapeTypes.TextBox;
+ public final static short OBJECT_TYPE_MICROSOFT_OFFICE_DRAWING = 30;
+
+ public final static int WRAP_SQUARE = 0;
+ public final static int WRAP_BY_POINTS = 1;
+ public final static int WRAP_NONE = 2;
+
+ private TextObjectRecord _textObjectRecord;
+
+ public HSSFSimpleShape(EscherContainerRecord spContainer, ObjRecord objRecord, TextObjectRecord textObjectRecord) {
+ super(spContainer, objRecord);
+ this._textObjectRecord = textObjectRecord;
+ }
- int shapeType = OBJECT_TYPE_LINE;
+ public HSSFSimpleShape(EscherContainerRecord spContainer, ObjRecord objRecord) {
+ super(spContainer, objRecord);
+ }
- public HSSFSimpleShape( HSSFShape parent, HSSFAnchor anchor )
+ public HSSFSimpleShape( HSSFShape parent, HSSFAnchor anchor)
{
super( parent, anchor );
+ _textObjectRecord = createTextObjRecord();
+ }
+
+ protected TextObjectRecord getTextObjectRecord() {
+ return _textObjectRecord;
+ }
+
+ protected TextObjectRecord createTextObjRecord(){
+ TextObjectRecord obj = new TextObjectRecord();
+ obj.setHorizontalTextAlignment(2);
+ obj.setVerticalTextAlignment(2);
+ obj.setTextLocked(true);
+ obj.setTextOrientation(TextObjectRecord.TEXT_ORIENTATION_NONE);
+ obj.setStr(new HSSFRichTextString(""));
+ return obj;
+ }
+
+ @Override
+ protected EscherContainerRecord createSpContainer() {
+ EscherContainerRecord spContainer = new EscherContainerRecord();
+ spContainer.setRecordId( EscherContainerRecord.SP_CONTAINER );
+ spContainer.setOptions( (short) 0x000F );
+
+ EscherSpRecord sp = new EscherSpRecord();
+ sp.setRecordId( EscherSpRecord.RECORD_ID );
+ sp.setFlags( EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE );
+ sp.setVersion((short) 0x2);
+
+ EscherClientDataRecord clientData = new EscherClientDataRecord();
+ clientData.setRecordId( EscherClientDataRecord.RECORD_ID );
+ clientData.setOptions( (short) (0x0000) );
+
+ EscherOptRecord optRecord = new EscherOptRecord();
+ optRecord.setEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEDASHING, LINESTYLE_SOLID));
+ optRecord.setEscherProperty( new EscherBoolProperty( EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x00080008));
+// optRecord.setEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEWIDTH, LINEWIDTH_DEFAULT));
+ optRecord.setEscherProperty(new EscherRGBProperty(EscherProperties.FILL__FILLCOLOR, FILL__FILLCOLOR_DEFAULT));
+ optRecord.setEscherProperty(new EscherRGBProperty(EscherProperties.LINESTYLE__COLOR, LINESTYLE__COLOR_DEFAULT));
+ optRecord.setEscherProperty(new EscherBoolProperty(EscherProperties.FILL__NOFILLHITTEST, NO_FILLHITTEST_FALSE));
+ optRecord.setEscherProperty( new EscherBoolProperty( EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x00080008));
+
+ optRecord.setEscherProperty( new EscherShapePathProperty( EscherProperties.GEOMETRY__SHAPEPATH, EscherShapePathProperty.COMPLEX ) );
+ optRecord.setEscherProperty(new EscherBoolProperty( EscherProperties.GROUPSHAPE__PRINT, 0x080000));
+ optRecord.setRecordId( EscherOptRecord.RECORD_ID );
+
+ EscherTextboxRecord escherTextbox = new EscherTextboxRecord();
+ escherTextbox.setRecordId(EscherTextboxRecord.RECORD_ID);
+ escherTextbox.setOptions((short) 0x0000);
+
+ spContainer.addChildRecord(sp);
+ spContainer.addChildRecord(optRecord);
+ spContainer.addChildRecord(getAnchor().getEscherAnchor());
+ spContainer.addChildRecord(clientData);
+ spContainer.addChildRecord(escherTextbox);
+ return spContainer;
+ }
+
+ @Override
+ protected ObjRecord createObjRecord() {
+ ObjRecord obj = new ObjRecord();
+ CommonObjectDataSubRecord c = new CommonObjectDataSubRecord();
+ c.setLocked(true);
+ c.setPrintable(true);
+ c.setAutofill(true);
+ c.setAutoline(true);
+ EndSubRecord e = new EndSubRecord();
+
+ obj.addSubRecord(c);
+ obj.addSubRecord(e);
+ return obj;
+ }
+
+ @Override
+ protected void afterRemove(HSSFPatriarch patriarch) {
+ patriarch._getBoundAggregate().removeShapeToObjRecord(getEscherContainer().getChildById(EscherClientDataRecord.RECORD_ID));
+ if (null != getEscherContainer().getChildById(EscherTextboxRecord.RECORD_ID)){
+ patriarch._getBoundAggregate().removeShapeToObjRecord(getEscherContainer().getChildById(EscherTextboxRecord.RECORD_ID));
+ }
+ }
+
+ /**
+ * @return the rich text string for this textbox.
+ */
+ public HSSFRichTextString getString() {
+ return _textObjectRecord.getStr();
}
/**
+ * @param string Sets the rich text string used by this object.
+ */
+ public void setString(RichTextString string) {
+ //TODO add other shape types which can not contain text
+ if (getShapeType() == 0 || getShapeType() == OBJECT_TYPE_LINE){
+ throw new IllegalStateException("Cannot set text for shape type: "+getShapeType());
+ }
+ HSSFRichTextString rtr = (HSSFRichTextString) string;
+ // If font is not set we must set the default one
+ if (rtr.numFormattingRuns() == 0) rtr.applyFont((short) 0);
+ _textObjectRecord.setStr(rtr);
+ if (string.getString() != null){
+ setPropertyValue(new EscherSimpleProperty(EscherProperties.TEXT__TEXTID, string.getString().hashCode()));
+ }
+ }
+
+ @Override
+ void afterInsert(HSSFPatriarch patriarch){
+ EscherAggregate agg = patriarch._getBoundAggregate();
+ agg.associateShapeToObjRecord(getEscherContainer().getChildById(EscherClientDataRecord.RECORD_ID), getObjRecord());
+
+ if (null != getTextObjectRecord()){
+ agg.associateShapeToObjRecord(getEscherContainer().getChildById(EscherTextboxRecord.RECORD_ID), getTextObjectRecord());
+ }
+ }
+
+ @Override
+ protected HSSFShape cloneShape() {
+ TextObjectRecord txo = null;
+ EscherContainerRecord spContainer = new EscherContainerRecord();
+ byte [] inSp = getEscherContainer().serialize();
+ spContainer.fillFields(inSp, 0, new DefaultEscherRecordFactory());
+ ObjRecord obj = (ObjRecord) getObjRecord().cloneViaReserialise();
+ if (getTextObjectRecord() != null && getString() != null && null != getString().getString()){
+ txo = (TextObjectRecord) getTextObjectRecord().cloneViaReserialise();
+ }
+ return new HSSFSimpleShape(spContainer, obj, txo);
+ }
+
+
+ /**
* Gets the shape type.
* @return One of the OBJECT_TYPE_* constants.
*
@@ -67,19 +210,28 @@ public class HSSFSimpleShape
* @see #OBJECT_TYPE_PICTURE
* @see #OBJECT_TYPE_COMMENT
*/
- public int getShapeType() { return shapeType; }
+ public int getShapeType() {
+ EscherSpRecord spRecord = getEscherContainer().getChildById(EscherSpRecord.RECORD_ID);
+ return spRecord.getShapeType();
+ }
+
+ public int getWrapText(){
+ EscherSimpleProperty property = getOptRecord().lookup(EscherProperties.TEXT__WRAPTEXT);
+ return null == property ? WRAP_SQUARE : property.getPropertyValue();
+ }
+
+ public void setWrapText(int value){
+ setPropertyValue(new EscherSimpleProperty(EscherProperties.TEXT__WRAPTEXT, false, false, value));
+ }
/**
- * Sets the shape types.
- *
- * @param shapeType One of the OBJECT_TYPE_* constants.
- *
- * @see #OBJECT_TYPE_LINE
- * @see #OBJECT_TYPE_OVAL
- * @see #OBJECT_TYPE_RECTANGLE
- * @see #OBJECT_TYPE_PICTURE
- * @see #OBJECT_TYPE_COMMENT
+ * @see HSSFShapeTypes
+ * @param value - shapeType
*/
- public void setShapeType( int shapeType ){ this.shapeType = shapeType; }
-
+ public void setShapeType(int value){
+ CommonObjectDataSubRecord cod = (CommonObjectDataSubRecord) getObjRecord().getSubRecords().get(0);
+ cod.setObjectType(OBJECT_TYPE_MICROSOFT_OFFICE_DRAWING);
+ EscherSpRecord spRecord = getEscherContainer().getChildById(EscherSpRecord.RECORD_ID);
+ spRecord.setShapeType((short) value);
+ }
}
Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFTextbox.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFTextbox.java?rev=1371663&r1=1371662&r2=1371663&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFTextbox.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFTextbox.java Fri Aug 10 11:30:42 2012
@@ -17,6 +17,8 @@
package org.apache.poi.hssf.usermodel;
+import org.apache.poi.ddf.*;
+import org.apache.poi.hssf.record.*;
import org.apache.poi.ss.usermodel.RichTextString;
/**
@@ -24,163 +26,222 @@ import org.apache.poi.ss.usermodel.RichT
*
* @author Glen Stampoultzis (glens at apache.org)
*/
-public class HSSFTextbox
- extends HSSFSimpleShape
-{
- public final static short OBJECT_TYPE_TEXT = 6;
+public class HSSFTextbox extends HSSFSimpleShape {
+ public final static short OBJECT_TYPE_TEXT = 6;
/**
* How to align text horizontally
*/
- public final static short HORIZONTAL_ALIGNMENT_LEFT = 1;
- public final static short HORIZONTAL_ALIGNMENT_CENTERED = 2;
- public final static short HORIZONTAL_ALIGNMENT_RIGHT = 3;
- public final static short HORIZONTAL_ALIGNMENT_JUSTIFIED = 4;
- public final static short HORIZONTAL_ALIGNMENT_DISTRIBUTED = 7;
+ public final static short HORIZONTAL_ALIGNMENT_LEFT = 1;
+ public final static short HORIZONTAL_ALIGNMENT_CENTERED = 2;
+ public final static short HORIZONTAL_ALIGNMENT_RIGHT = 3;
+ public final static short HORIZONTAL_ALIGNMENT_JUSTIFIED = 4;
+ public final static short HORIZONTAL_ALIGNMENT_DISTRIBUTED = 7;
/**
* How to align text vertically
*/
- public final static short VERTICAL_ALIGNMENT_TOP = 1;
- public final static short VERTICAL_ALIGNMENT_CENTER = 2;
- public final static short VERTICAL_ALIGNMENT_BOTTOM = 3;
- public final static short VERTICAL_ALIGNMENT_JUSTIFY = 4;
- public final static short VERTICAL_ALIGNMENT_DISTRIBUTED= 7;
+ public final static short VERTICAL_ALIGNMENT_TOP = 1;
+ public final static short VERTICAL_ALIGNMENT_CENTER = 2;
+ public final static short VERTICAL_ALIGNMENT_BOTTOM = 3;
+ public final static short VERTICAL_ALIGNMENT_JUSTIFY = 4;
+ public final static short VERTICAL_ALIGNMENT_DISTRIBUTED = 7;
-
- int marginLeft, marginRight, marginTop, marginBottom;
- short halign, valign;
+ public HSSFTextbox(EscherContainerRecord spContainer, ObjRecord objRecord, TextObjectRecord textObjectRecord) {
+ super(spContainer, objRecord, textObjectRecord);
+ }
HSSFRichTextString string = new HSSFRichTextString("");
/**
* Construct a new textbox with the given parent and anchor.
+ *
* @param parent
- * @param anchor One of HSSFClientAnchor or HSSFChildAnchor
- */
- public HSSFTextbox( HSSFShape parent, HSSFAnchor anchor )
- {
- super( parent, anchor );
- setShapeType(OBJECT_TYPE_TEXT);
-
- halign = HORIZONTAL_ALIGNMENT_LEFT;
- valign = VERTICAL_ALIGNMENT_TOP;
- }
-
- /**
- * @return the rich text string for this textbox.
+ * @param anchor One of HSSFClientAnchor or HSSFChildAnchor
*/
- public HSSFRichTextString getString()
- {
- return string;
- }
-
- /**
- * @param string Sets the rich text string used by this object.
- */
- public void setString( RichTextString string )
- {
- HSSFRichTextString rtr = (HSSFRichTextString)string;
-
- // If font is not set we must set the default one
- if (rtr.numFormattingRuns() == 0) rtr.applyFont((short)0);
-
- this.string = rtr;
- }
-
- /**
- * @return Returns the left margin within the textbox.
- */
- public int getMarginLeft()
- {
- return marginLeft;
+ public HSSFTextbox(HSSFShape parent, HSSFAnchor anchor) {
+ super(parent, anchor);
+ setHorizontalAlignment(HORIZONTAL_ALIGNMENT_LEFT);
+ setVerticalAlignment(VERTICAL_ALIGNMENT_TOP);
+ setString(new HSSFRichTextString(""));
+ }
+
+ @Override
+ protected ObjRecord createObjRecord() {
+ ObjRecord obj = new ObjRecord();
+ CommonObjectDataSubRecord c = new CommonObjectDataSubRecord();
+ c.setObjectType(HSSFTextbox.OBJECT_TYPE_TEXT);
+ c.setLocked(true);
+ c.setPrintable(true);
+ c.setAutofill(true);
+ c.setAutoline(true);
+ EndSubRecord e = new EndSubRecord();
+ obj.addSubRecord(c);
+ obj.addSubRecord(e);
+ return obj;
+ }
+
+ @Override
+ protected EscherContainerRecord createSpContainer() {
+ EscherContainerRecord spContainer = new EscherContainerRecord();
+ EscherSpRecord sp = new EscherSpRecord();
+ EscherOptRecord opt = new EscherOptRecord();
+ EscherClientDataRecord clientData = new EscherClientDataRecord();
+ EscherTextboxRecord escherTextbox = new EscherTextboxRecord();
+
+ spContainer.setRecordId(EscherContainerRecord.SP_CONTAINER);
+ spContainer.setOptions((short) 0x000F);
+ sp.setRecordId(EscherSpRecord.RECORD_ID);
+ sp.setOptions((short) ((EscherAggregate.ST_TEXTBOX << 4) | 0x2));
+
+ sp.setFlags(EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE);
+ opt.setRecordId(EscherOptRecord.RECORD_ID);
+ opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.TEXT__TEXTID, 0));
+ opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.TEXT__WRAPTEXT, 0));
+ opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.TEXT__ANCHORTEXT, 0));
+ opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.GROUPSHAPE__PRINT, 0x00080000));
+
+ opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.TEXT__TEXTLEFT, 0));
+ opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.TEXT__TEXTRIGHT, 0));
+ opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.TEXT__TEXTTOP, 0));
+ opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.TEXT__TEXTBOTTOM, 0));
+
+ opt.setEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEDASHING, LINESTYLE_SOLID));
+ opt.setEscherProperty(new EscherBoolProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x00080008));
+ opt.setEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEWIDTH, LINEWIDTH_DEFAULT));
+ opt.setEscherProperty(new EscherRGBProperty(EscherProperties.FILL__FILLCOLOR, FILL__FILLCOLOR_DEFAULT));
+ opt.setEscherProperty(new EscherRGBProperty(EscherProperties.LINESTYLE__COLOR, LINESTYLE__COLOR_DEFAULT));
+ opt.setEscherProperty(new EscherBoolProperty(EscherProperties.FILL__NOFILLHITTEST, NO_FILLHITTEST_FALSE));
+ opt.setEscherProperty(new EscherBoolProperty(EscherProperties.GROUPSHAPE__PRINT, 0x080000));
+
+ EscherRecord anchor = getAnchor().getEscherAnchor();
+ clientData.setRecordId(EscherClientDataRecord.RECORD_ID);
+ clientData.setOptions((short) 0x0000);
+ escherTextbox.setRecordId(EscherTextboxRecord.RECORD_ID);
+ escherTextbox.setOptions((short) 0x0000);
+
+ spContainer.addChildRecord(sp);
+ spContainer.addChildRecord(opt);
+ spContainer.addChildRecord(anchor);
+ spContainer.addChildRecord(clientData);
+ spContainer.addChildRecord(escherTextbox);
+
+ return spContainer;
+ }
+
+ @Override
+ void afterInsert(HSSFPatriarch patriarch) {
+ EscherAggregate agg = patriarch._getBoundAggregate();
+ agg.associateShapeToObjRecord(getEscherContainer().getChildById(EscherClientDataRecord.RECORD_ID), getObjRecord());
+ agg.associateShapeToObjRecord(getEscherContainer().getChildById(EscherTextboxRecord.RECORD_ID), getTextObjectRecord());
+ }
+
+ /**
+ * @return Returns the left margin within the textbox.
+ */
+ public int getMarginLeft() {
+ EscherSimpleProperty property = getOptRecord().lookup(EscherProperties.TEXT__TEXTLEFT);
+ return property == null ? 0 : property.getPropertyValue();
}
/**
* Sets the left margin within the textbox.
*/
- public void setMarginLeft( int marginLeft )
- {
- this.marginLeft = marginLeft;
+ public void setMarginLeft(int marginLeft) {
+ setPropertyValue(new EscherSimpleProperty(EscherProperties.TEXT__TEXTLEFT, marginLeft));
}
/**
- * @return returns the right margin within the textbox.
+ * @return returns the right margin within the textbox.
*/
- public int getMarginRight()
- {
- return marginRight;
+ public int getMarginRight() {
+ EscherSimpleProperty property = getOptRecord().lookup(EscherProperties.TEXT__TEXTRIGHT);
+ return property == null ? 0 : property.getPropertyValue();
}
/**
* Sets the right margin within the textbox.
*/
- public void setMarginRight( int marginRight )
- {
- this.marginRight = marginRight;
+ public void setMarginRight(int marginRight) {
+ setPropertyValue(new EscherSimpleProperty(EscherProperties.TEXT__TEXTRIGHT, marginRight));
}
/**
- * @return returns the top margin within the textbox.
+ * @return returns the top margin within the textbox.
*/
- public int getMarginTop()
- {
- return marginTop;
+ public int getMarginTop() {
+ EscherSimpleProperty property = getOptRecord().lookup(EscherProperties.TEXT__TEXTTOP);
+ return property == null ? 0 : property.getPropertyValue();
}
/**
* Sets the top margin within the textbox.
*/
- public void setMarginTop( int marginTop )
- {
- this.marginTop = marginTop;
+ public void setMarginTop(int marginTop) {
+ setPropertyValue(new EscherSimpleProperty(EscherProperties.TEXT__TEXTTOP, marginTop));
}
/**
* Gets the bottom margin within the textbox.
*/
- public int getMarginBottom()
- {
- return marginBottom;
+ public int getMarginBottom() {
+ EscherSimpleProperty property = getOptRecord().lookup(EscherProperties.TEXT__TEXTBOTTOM);
+ return property == null ? 0 : property.getPropertyValue();
}
/**
* Sets the bottom margin within the textbox.
*/
- public void setMarginBottom( int marginBottom )
- {
- this.marginBottom = marginBottom;
+ public void setMarginBottom(int marginBottom) {
+ setPropertyValue(new EscherSimpleProperty(EscherProperties.TEXT__TEXTBOTTOM, marginBottom));
}
/**
* Gets the horizontal alignment.
*/
- public short getHorizontalAlignment()
- {
- return halign;
+ public short getHorizontalAlignment() {
+ return (short) getTextObjectRecord().getHorizontalTextAlignment();
}
/**
* Sets the horizontal alignment.
*/
- public void setHorizontalAlignment( short align )
- {
- this.halign = align;
+ public void setHorizontalAlignment(short align) {
+ getTextObjectRecord().setHorizontalTextAlignment(align);
}
/**
* Gets the vertical alignment.
*/
- public short getVerticalAlignment()
- {
- return valign;
+ public short getVerticalAlignment() {
+ return (short) getTextObjectRecord().getVerticalTextAlignment();
}
/**
* Sets the vertical alignment.
*/
- public void setVerticalAlignment( short align )
- {
- this.valign = align;
+ public void setVerticalAlignment(short align) {
+ getTextObjectRecord().setVerticalTextAlignment(align);
+ }
+
+ @Override
+ public void setShapeType(int shapeType) {
+ throw new IllegalStateException("Shape type can not be changed in " + this.getClass().getSimpleName());
+ }
+
+ @Override
+ protected HSSFShape cloneShape() {
+ TextObjectRecord txo = (TextObjectRecord) getTextObjectRecord().cloneViaReserialise();
+ EscherContainerRecord spContainer = new EscherContainerRecord();
+ byte[] inSp = getEscherContainer().serialize();
+ spContainer.fillFields(inSp, 0, new DefaultEscherRecordFactory());
+ ObjRecord obj = (ObjRecord) getObjRecord().cloneViaReserialise();
+ return new HSSFTextbox(spContainer, obj, txo);
+ }
+
+ @Override
+ protected void afterRemove(HSSFPatriarch patriarch) {
+ patriarch._getBoundAggregate().removeShapeToObjRecord(getEscherContainer().getChildById(EscherClientDataRecord.RECORD_ID));
+ patriarch._getBoundAggregate().removeShapeToObjRecord(getEscherContainer().getChildById(EscherTextboxRecord.RECORD_ID));
}
}
Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java?rev=1371663&r1=1371662&r2=1371663&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java Fri Aug 10 11:30:42 2012
@@ -696,7 +696,7 @@ public final class HSSFWorkbook extends
names.add(newName);
}
// TODO - maybe same logic required for other/all built-in name records
- workbook.cloneDrawings(clonedSheet.getSheet());
+// workbook.cloneDrawings(clonedSheet.getSheet());
return clonedSheet;
}
@@ -1606,7 +1606,7 @@ public final class HSSFWorkbook extends
r.setUid( uid );
r.setTag( (short) 0xFF );
r.setSize( pictureData.length + 25 );
- r.setRef( 1 );
+ r.setRef( 0 );
r.setOffset( 0 );
r.setBlipRecord( blipRecord );
@@ -1698,7 +1698,7 @@ public final class HSSFWorkbook extends
List<HSSFObjectData> objects = new ArrayList<HSSFObjectData>();
for (int i = 0; i < getNumberOfSheets(); i++)
{
- getAllEmbeddedObjects(getSheetAt(i).getSheet().getRecords(), objects);
+ getAllEmbeddedObjects(getSheetAt(i), objects);
}
return objects;
}
@@ -1706,27 +1706,20 @@ public final class HSSFWorkbook extends
/**
* Gets all embedded OLE2 objects from the Workbook.
*
- * @param records the list of records to search.
+ * @param sheet embedded object attached to
* @param objects the list of embedded objects to populate.
*/
- private void getAllEmbeddedObjects(List<RecordBase> records, List<HSSFObjectData> objects)
+ private void getAllEmbeddedObjects(HSSFSheet sheet, List<HSSFObjectData> objects)
{
- for (RecordBase obj : records) {
- if (obj instanceof ObjRecord)
- {
- // TODO: More convenient way of determining if there is stored binary.
- // TODO: Link to the data stored in the other stream.
- Iterator<SubRecord> subRecordIter = ((ObjRecord) obj).getSubRecords().iterator();
- while (subRecordIter.hasNext())
- {
- SubRecord sub = subRecordIter.next();
- if (sub instanceof EmbeddedObjectRefSubRecord)
- {
- objects.add(new HSSFObjectData((ObjRecord) obj, directory));
- }
- }
- }
- }
+ HSSFPatriarch patriarch = sheet.getDrawingPatriarch();
+ if (null == patriarch){
+ return;
+ }
+ for (HSSFShape shape: patriarch.getChildren()){
+ if (shape instanceof HSSFObjectData){
+ objects.add((HSSFObjectData) shape);
+ }
+ }
}
public HSSFCreationHelper getCreationHelper() {
@@ -1800,4 +1793,8 @@ public final class HSSFWorkbook extends
public boolean changeExternalReference(String oldUrl, String newUrl) {
return workbook.changeExternalReference(oldUrl, newUrl);
}
+
+ public DirectoryNode getRootDirectory(){
+ return directory;
+ }
}
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDrawingRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDrawingRecord.java?rev=1371663&r1=1371662&r2=1371663&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDrawingRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDrawingRecord.java Fri Aug 10 11:30:42 2012
@@ -49,17 +49,12 @@ public final class TestDrawingRecord ext
out.write(cn.serialize());
List<Record> rec = RecordFactory.createRecords(new ByteArrayInputStream(out.toByteArray()));
- assertEquals(1, rec.size());
+ assertEquals(2, rec.size());
assertTrue(rec.get(0) instanceof DrawingRecord);
+ assertTrue(rec.get(1) instanceof ContinueRecord);
- //DrawingRecord.getData() should return concatenated data1 and data2
- byte[] tmp = new byte[data1.length + data2.length];
- System.arraycopy(data1, 0, tmp, 0, data1.length);
- System.arraycopy(data2, 0, tmp, data1.length, data2.length);
-
- DrawingRecord dg2 = (DrawingRecord)rec.get(0);
- assertEquals(data1.length + data2.length, dg2.getData().length);
- assertTrue(Arrays.equals(tmp, dg2.getData()));
+ assertTrue(Arrays.equals(data1, ((DrawingRecord)rec.get(0)).getData()));
+ assertTrue(Arrays.equals(data2, ((ContinueRecord)rec.get(1)).getData()));
}
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/HSSFTestHelper.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/HSSFTestHelper.java?rev=1371663&r1=1371662&r2=1371663&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/HSSFTestHelper.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/HSSFTestHelper.java Fri Aug 10 11:30:42 2012
@@ -16,8 +16,18 @@
==================================================================== */
package org.apache.poi.hssf.usermodel;
+import org.apache.poi.ddf.*;
+import org.apache.poi.hssf.model.DrawingManager2;
import org.apache.poi.hssf.model.InternalSheet;
import org.apache.poi.hssf.model.InternalWorkbook;
+import org.apache.poi.hssf.record.EscherAggregate;
+import org.apache.poi.hssf.record.ObjRecord;
+import org.apache.poi.hssf.record.TextObjectRecord;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Map;
/**
* Helper class for HSSF tests that aren't within the
@@ -25,6 +35,33 @@ import org.apache.poi.hssf.model.Interna
* UserModel things.
*/
public class HSSFTestHelper {
+
+ public static class MockDrawingManager extends DrawingManager2 {
+
+ public MockDrawingManager (){
+ super(null);
+ }
+
+ @Override
+ public int allocateShapeId(short drawingGroupId) {
+ return 1025; //Mock value
+ }
+
+ @Override
+ public int allocateShapeId(short drawingGroupId, EscherDgRecord dg) {
+ return 1025;
+ }
+
+ public EscherDgRecord createDgRecord()
+ {
+ EscherDgRecord dg = new EscherDgRecord();
+ dg.setRecordId( EscherDgRecord.RECORD_ID );
+ dg.setOptions( (short) (16) );
+ dg.setNumShapes( 1 );
+ dg.setLastMSOSPID( 1024 );
+ return dg;
+ }
+ }
/**
* Lets non UserModel tests at the low level Workbook
*/
@@ -34,4 +71,55 @@ public class HSSFTestHelper {
public static InternalSheet getSheetForTest(HSSFSheet sheet) {
return sheet.getSheet();
}
+
+ public static HSSFPatriarch createTestPatriarch(HSSFSheet sheet, EscherAggregate agg){
+ return new HSSFPatriarch(sheet, agg);
+ }
+
+ public static EscherAggregate getEscherAggregate(HSSFPatriarch patriarch){
+ return patriarch._getBoundAggregate();
+ }
+
+ public static int allocateNewShapeId(HSSFPatriarch patriarch){
+ return patriarch.newShapeId();
+ }
+
+ public static EscherOptRecord getOptRecord(HSSFShape shape){
+ return shape.getOptRecord();
+ }
+
+ public static void convertHSSFGroup(HSSFShapeGroup shape, EscherContainerRecord escherParent, Map shapeToObj){
+ Class clazz = EscherAggregate.class;
+ try {
+ Method method = clazz.getDeclaredMethod("convertGroup", HSSFShapeGroup.class, EscherContainerRecord.class, Map.class);
+ method.setAccessible(true);
+ method.invoke(new EscherAggregate(new MockDrawingManager()), shape, escherParent, shapeToObj);
+ } catch (NoSuchMethodException e) {
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static void setShapeId(HSSFShape shape, int id){
+ shape.setShapeId(id);
+ }
+
+ public static EscherContainerRecord getEscherContainer(HSSFShape shape){
+ return shape.getEscherContainer();
+ }
+
+ public static TextObjectRecord getTextObjRecord(HSSFSimpleShape shape){
+ return shape.getTextObjectRecord();
+ }
+
+ public static ObjRecord getObjRecord(HSSFShape shape){
+ return shape.getObjRecord();
+ }
+
+ public static EscherRecord getEscherAnchor(HSSFAnchor anchor){
+ return anchor.getEscherAnchor();
+ }
}
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java?rev=1371663&r1=1371662&r2=1371663&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java Fri Aug 10 11:30:42 2012
@@ -24,9 +24,12 @@ import org.apache.poi.hssf.HSSFITestData
import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.OldExcelFormatException;
import org.apache.poi.hssf.extractor.ExcelExtractor;
+import org.apache.poi.hssf.model.InternalSheet;
import org.apache.poi.hssf.model.InternalWorkbook;
import org.apache.poi.hssf.record.*;
import org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate;
+import org.apache.poi.hssf.record.aggregates.PageSettingsBlock;
+import org.apache.poi.hssf.record.aggregates.RecordAggregate;
import org.apache.poi.hssf.record.common.UnicodeString;
import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
@@ -2238,4 +2241,31 @@ if(1==2) {
// make sure we are still readable
writeOutAndReadBack(workbook);
}
+
+ public void test51675(){
+ final List<Short> list = new ArrayList<Short>();
+ HSSFWorkbook workbook = openSample("51675.xls");
+ HSSFSheet sh = workbook.getSheetAt(0);
+ InternalSheet ish = HSSFTestHelper.getSheetForTest(sh);
+ PageSettingsBlock psb = (PageSettingsBlock) ish.getRecords().get(13);
+ psb.visitContainedRecords(new RecordAggregate.RecordVisitor() {
+ public void visitRecord(Record r) {
+ list.add(r.getSid());
+ }
+ });
+ assertTrue(list.get(list.size()-1).intValue() == UnknownRecord.BITMAP_00E9);
+ assertTrue(list.get(list.size()-2).intValue() == UnknownRecord.HEADER_FOOTER_089C);
+ }
+
+ public void test52272(){
+ HSSFWorkbook wb = new HSSFWorkbook();
+ HSSFSheet sh = wb.createSheet();
+ HSSFPatriarch p = sh.createDrawingPatriarch();
+
+ HSSFSimpleShape s = p.createSimpleShape(new HSSFClientAnchor());
+ s.setShapeType(HSSFSimpleShape.OBJECT_TYPE_LINE);
+
+ HSSFSheet sh2 = wb.cloneSheet(0);
+ assertNotNull(sh2.getDrawingPatriarch());
+ }
}
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestCloneSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestCloneSheet.java?rev=1371663&r1=1371662&r2=1371663&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestCloneSheet.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestCloneSheet.java Fri Aug 10 11:30:42 2012
@@ -19,8 +19,14 @@ package org.apache.poi.hssf.usermodel;
import junit.framework.TestCase;
+import org.apache.poi.ddf.EscherDgRecord;
+import org.apache.poi.ddf.EscherSpRecord;
+import org.apache.poi.hssf.record.EscherAggregate;
import org.apache.poi.ss.util.CellRangeAddress;
+import java.io.IOException;
+import java.util.Arrays;
+
/**
* Test the ability to clone a sheet.
* If adding new records that belong to a sheet (as opposed to a book)
@@ -55,4 +61,74 @@ public final class TestCloneSheet extend
assertTrue("Row 3 still should be broken", clone.isRowBroken(3));
}
+
+ public void testCloneSheetWithoutDrawings(){
+ HSSFWorkbook b = new HSSFWorkbook();
+ HSSFSheet s = b.createSheet("Test");
+ HSSFSheet s2 = s.cloneSheet(b);
+
+ assertNull(s.getDrawingPatriarch());
+ assertNull(s2.getDrawingPatriarch());
+ assertEquals(HSSFTestHelper.getSheetForTest(s).getRecords().size(), HSSFTestHelper.getSheetForTest(s2).getRecords().size());
+ }
+
+ public void testCloneSheetWithEmptyDrawingAggregate(){
+ HSSFWorkbook b = new HSSFWorkbook();
+ HSSFSheet s = b.createSheet("Test");
+ HSSFPatriarch patriarch = s.createDrawingPatriarch();
+
+ EscherAggregate agg1 = patriarch._getBoundAggregate();
+
+ HSSFSheet s2 = s.cloneSheet(b);
+
+ patriarch = s2.getDrawingPatriarch();
+
+ EscherAggregate agg2 = patriarch._getBoundAggregate();
+
+ EscherSpRecord sp1 = (EscherSpRecord) agg1.getEscherContainer().getChild(1).getChild(0).getChild(1);
+ EscherSpRecord sp2 = (EscherSpRecord) agg2.getEscherContainer().getChild(1).getChild(0).getChild(1);
+
+ assertEquals(sp1.getShapeId(), 1024);
+ assertEquals(sp2.getShapeId(), 2048);
+
+ EscherDgRecord dg = (EscherDgRecord) agg2.getEscherContainer().getChild(0);
+
+ assertEquals(dg.getLastMSOSPID(), 2048);
+ assertEquals(dg.getInstance(), 0x2);
+
+ //everything except id and DgRecord.lastMSOSPID and DgRecord.Instance must be the same
+
+ sp2.setShapeId(1024);
+ dg.setLastMSOSPID(1024);
+ dg.setInstance((short) 0x1);
+
+ assertEquals(agg1.serialize().length, agg2.serialize().length);
+ assertEquals(agg1.toXml(""), agg2.toXml(""));
+ assertTrue(Arrays.equals(agg1.serialize(), agg2.serialize()));
+ }
+
+ public void testCloneComment() throws IOException {
+ HSSFWorkbook wb = new HSSFWorkbook();
+ HSSFSheet sh = wb.createSheet();
+ HSSFPatriarch p = sh.createDrawingPatriarch();
+ HSSFComment c = p.createComment(new HSSFClientAnchor(0,0,100,100, (short) 0,0,(short)5,5));
+ c.setColumn(1);
+ c.setRow(2);
+ c.setString(new HSSFRichTextString("qwertyuio"));
+
+ HSSFSheet sh2 = wb.cloneSheet(0);
+ HSSFPatriarch p2 = sh2.getDrawingPatriarch();
+ HSSFComment c2 = (HSSFComment) p2.getChildren().get(0);
+
+ assertTrue(Arrays.equals(c2.getTextObjectRecord().serialize(), c.getTextObjectRecord().serialize()));
+ assertTrue(Arrays.equals(c2.getObjRecord().serialize(), c.getObjRecord().serialize()));
+ assertTrue(Arrays.equals(c2.getNoteRecord().serialize(), c.getNoteRecord().serialize()));
+
+
+ //everything except spRecord.shapeId must be the same
+ assertFalse(Arrays.equals(c2.getEscherContainer().serialize(), c.getEscherContainer().serialize()));
+ EscherSpRecord sp = (EscherSpRecord) c2.getEscherContainer().getChild(0);
+ sp.setShapeId(1025);
+ assertTrue(Arrays.equals(c2.getEscherContainer().serialize(), c.getEscherContainer().serialize()));
+ }
}
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java?rev=1371663&r1=1371662&r2=1371663&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java Fri Aug 10 11:30:42 2012
@@ -32,7 +32,7 @@ public final class TestHSSFComment exten
}
public void testDefaultShapeType() {
- HSSFComment comment = new HSSFComment((HSSFShape)null, (HSSFAnchor)null);
+ HSSFComment comment = new HSSFComment((HSSFShape)null, new HSSFClientAnchor());
assertEquals(HSSFSimpleShape.OBJECT_TYPE_COMMENT, comment.getShapeType());
}
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPicture.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPicture.java?rev=1371663&r1=1371662&r2=1371663&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPicture.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPicture.java Fri Aug 10 11:30:42 2012
@@ -17,8 +17,10 @@
package org.apache.poi.hssf.usermodel;
+import org.apache.poi.ddf.EscherBSERecord;
import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.HSSFITestDataProvider;
+import org.apache.poi.hssf.model.InternalSheet;
import org.apache.poi.ss.usermodel.BaseTestPicture;
import org.apache.poi.ss.usermodel.PictureData;
import org.apache.poi.ss.usermodel.Workbook;
@@ -149,4 +151,63 @@ public final class TestHSSFPicture exten
assertTrue(Arrays.equals(data4, ((HSSFPicture)dr.getChildren().get(3)).getPictureData().getData()));
}
+ public void testBSEPictureRef(){
+ HSSFWorkbook wb = new HSSFWorkbook();
+
+ HSSFSheet sh = wb.createSheet("Pictures");
+ HSSFPatriarch dr = sh.createDrawingPatriarch();
+ HSSFClientAnchor anchor = new HSSFClientAnchor();
+
+ InternalSheet ish = HSSFTestHelper.getSheetForTest(sh);
+
+ //register a picture
+ byte[] data1 = new byte[]{1, 2, 3};
+ int idx1 = wb.addPicture(data1, Workbook.PICTURE_TYPE_JPEG);
+ assertEquals(1, idx1);
+ HSSFPicture p1 = dr.createPicture(anchor, idx1);
+
+ EscherBSERecord bse = wb.getWorkbook().getBSERecord(idx1);
+
+ assertEquals(bse.getRef(), 1);
+ dr.createPicture(new HSSFClientAnchor(), idx1);
+ assertEquals(bse.getRef(), 2);
+
+ HSSFShapeGroup gr = dr.createGroup(new HSSFClientAnchor());
+ gr.createPicture(new HSSFChildAnchor(), idx1);
+ assertEquals(bse.getRef(), 3);
+ }
+
+ public void testReadExistingImage(){
+ HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("drawings.xls");
+ HSSFSheet sheet = wb.getSheet("picture");
+ HSSFPatriarch drawing = sheet.getDrawingPatriarch();
+ assertEquals(1, drawing.getChildren().size());
+
+ HSSFPicture picture = (HSSFPicture) drawing.getChildren().get(0);
+ assertEquals(picture.getFileName(), "test");
+ }
+
+ public void testSetGetProperties(){
+ HSSFWorkbook wb = new HSSFWorkbook();
+
+ HSSFSheet sh = wb.createSheet("Pictures");
+ HSSFPatriarch dr = sh.createDrawingPatriarch();
+ HSSFClientAnchor anchor = new HSSFClientAnchor();
+
+ //register a picture
+ byte[] data1 = new byte[]{1, 2, 3};
+ int idx1 = wb.addPicture(data1, Workbook.PICTURE_TYPE_JPEG);
+ HSSFPicture p1 = dr.createPicture(anchor, idx1);
+
+ assertEquals(p1.getFileName(), "");
+ p1.setFileName("aaa");
+ assertEquals(p1.getFileName(), "aaa");
+
+ wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
+ sh = wb.getSheet("Pictures");
+ dr = sh.getDrawingPatriarch();
+
+ p1 = (HSSFPicture) dr.getChildren().get(0);
+ assertEquals(p1.getFileName(), "aaa");
+ }
}
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java?rev=1371663&r1=1371662&r2=1371663&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java Fri Aug 10 11:30:42 2012
@@ -824,8 +824,8 @@ public final class TestHSSFSheet extends
HSSFSheet sheet2 = wb2.getSheetAt(1);
//check that id of the drawing group was updated
- EscherDgRecord dg1 = (EscherDgRecord)sheet1.getDrawingEscherAggregate().findFirstWithId(EscherDgRecord.RECORD_ID);
- EscherDgRecord dg2 = (EscherDgRecord)sheet2.getDrawingEscherAggregate().findFirstWithId(EscherDgRecord.RECORD_ID);
+ EscherDgRecord dg1 = (EscherDgRecord)sheet1.getDrawingPatriarch()._getBoundAggregate().findFirstWithId(EscherDgRecord.RECORD_ID);
+ EscherDgRecord dg2 = (EscherDgRecord)sheet2.getDrawingPatriarch()._getBoundAggregate().findFirstWithId(EscherDgRecord.RECORD_ID);
int dg_id_1 = dg1.getOptions() >> 4;
int dg_id_2 = dg2.getOptions() >> 4;
assertEquals(dg_id_1 + 1, dg_id_2);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org