* Factory class for producing Excel Shapes from Escher records\r
*/\r
public class HSSFShapeFactory {\r
-\r
- private final static short OBJECT_TYPE_LINE = 1;\r
- private final static short OBJECT_TYPE_RECTANGLE = 2;\r
- private final static short OBJECT_TYPE_OVAL = 3;\r
- private final static short OBJECT_TYPE_ARC = 4;\r
- private final static short OBJECT_TYPE_PICTURE = 8;\r
-\r
/**\r
* build shape tree from escher container\r
* @param container root escher container from which escher records must be taken\r
return;\r
}\r
CommonObjectDataSubRecord cmo = (CommonObjectDataSubRecord) objRecord.getSubRecords().get(0);\r
- HSSFShape shape;\r
+ final HSSFShape shape;\r
switch (cmo.getObjectType()) {\r
case CommonObjectDataSubRecord.OBJECT_TYPE_PICTURE:\r
shape = new HSSFPicture(container, objRecord);\r
break;\r
case CommonObjectDataSubRecord.OBJECT_TYPE_MICROSOFT_OFFICE_DRAWING:\r
EscherOptRecord optRecord = container.getChildById(EscherOptRecord.RECORD_ID);\r
- EscherProperty property = optRecord.lookup(EscherProperties.GEOMETRY__VERTICES);\r
- if (null != property) {\r
- shape = new HSSFPolygon(container, objRecord, txtRecord);\r
+ if(optRecord == null) {\r
+ shape = new HSSFSimpleShape(container, objRecord, txtRecord);\r
} else {\r
- shape = new HSSFSimpleShape(container, objRecord, txtRecord);\r
+ EscherProperty property = optRecord.lookup(EscherProperties.GEOMETRY__VERTICES);\r
+ if (null != property) {\r
+ shape = new HSSFPolygon(container, objRecord, txtRecord);\r
+ } else {\r
+ shape = new HSSFSimpleShape(container, objRecord, txtRecord);\r
+ }\r
}\r
break;\r
case CommonObjectDataSubRecord.OBJECT_TYPE_TEXT:\r
package org.apache.poi.hssf.model;
import junit.framework.TestCase;
+
import org.apache.poi.hssf.record.CommonObjectDataSubRecord;
import org.apache.poi.hssf.usermodel.HSSFClientAnchor;
import org.apache.poi.hssf.usermodel.HSSFComment;
*
* See Bug 51332
*/
- public void testShapeId(){
+ @SuppressWarnings("deprecation")
+ public void testShapeId(){
HSSFClientAnchor anchor = new HSSFClientAnchor();
AbstractShape shape;