1 16 17 18 package org.apache.poi.hssf.model; 19 20 import org.apache.poi.ddf.*; 21 import org.apache.poi.hssf.record.*; 22 import org.apache.poi.hssf.usermodel.*; 23 24 29 public class LineShape 30 extends AbstractShape 31 { 32 private EscherContainerRecord spContainer; 33 private ObjRecord objRecord; 34 35 42 LineShape( HSSFSimpleShape hssfShape, int shapeId ) 43 { 44 spContainer = createSpContainer(hssfShape, shapeId); 45 objRecord = createObjRecord(hssfShape, shapeId); 46 } 47 48 51 private EscherContainerRecord createSpContainer(HSSFSimpleShape hssfShape, int shapeId) 52 { 53 HSSFShape shape = hssfShape; 54 55 EscherContainerRecord spContainer = new EscherContainerRecord(); 56 EscherSpRecord sp = new EscherSpRecord(); 57 EscherOptRecord opt = new EscherOptRecord(); 58 EscherRecord anchor = new EscherClientAnchorRecord(); 59 EscherClientDataRecord clientData = new EscherClientDataRecord(); 60 61 spContainer.setRecordId( EscherContainerRecord.SP_CONTAINER ); 62 spContainer.setOptions( (short) 0x000F ); 63 sp.setRecordId( EscherSpRecord.RECORD_ID ); 64 sp.setOptions( (short) ( (EscherAggregate.ST_LINE << 4) | 0x2 ) ); 65 66 sp.setShapeId( shapeId ); 67 sp.setFlags( EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE ); 68 opt.setRecordId( EscherOptRecord.RECORD_ID ); 69 opt.addEscherProperty( new EscherShapePathProperty( EscherProperties.GEOMETRY__SHAPEPATH, EscherShapePathProperty.COMPLEX ) ); 70 opt.addEscherProperty( new EscherBoolProperty( EscherProperties.LINESTYLE__NOLINEDRAWDASH, 1048592 ) ); 71 addStandardOptions(shape, opt); 72 HSSFAnchor userAnchor = shape.getAnchor(); 73 if (userAnchor.isHorizontallyFlipped()) 74 sp.setFlags(sp.getFlags() | EscherSpRecord.FLAG_FLIPHORIZ); 75 if (userAnchor.isVerticallyFlipped()) 76 sp.setFlags(sp.getFlags() | EscherSpRecord.FLAG_FLIPVERT); 77 anchor = createAnchor(userAnchor); 78 clientData.setRecordId( EscherClientDataRecord.RECORD_ID ); 79 clientData.setOptions( (short) 0x0000 ); 80 81 spContainer.addChildRecord(sp); 82 spContainer.addChildRecord(opt); 83 spContainer.addChildRecord(anchor); 84 spContainer.addChildRecord(clientData); 85 86 return spContainer; 87 } 88 89 92 private ObjRecord createObjRecord(HSSFShape hssfShape, int shapeId) 93 { 94 HSSFShape shape = hssfShape; 95 96 ObjRecord obj = new ObjRecord(); 97 CommonObjectDataSubRecord c = new CommonObjectDataSubRecord(); 98 c.setObjectType((short) ((HSSFSimpleShape)shape).getShapeType()); 99 c.setObjectId((short) ( shapeId )); 100 c.setLocked(true); 101 c.setPrintable(true); 102 c.setAutofill(true); 103 c.setAutoline(true); 104 EndSubRecord e = new EndSubRecord(); 105 106 obj.addSubRecord(c); 107 obj.addSubRecord(e); 108 109 return obj; 110 } 111 112 public EscherContainerRecord getSpContainer() 113 { 114 return spContainer; 115 } 116 117 public ObjRecord getObjRecord() 118 { 119 return objRecord; 120 } 121 122 } 123 | Popular Tags |