You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LineShape.java 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /* ====================================================================
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ==================================================================== */
  15. package org.apache.poi.hssf.model;
  16. import org.apache.poi.ddf.*;
  17. import org.apache.poi.hssf.record.*;
  18. import org.apache.poi.hssf.usermodel.*;
  19. /**
  20. * Represents a line shape and creates all the line specific low level records.
  21. *
  22. * @author Glen Stampoultzis (glens at apache.org)
  23. */
  24. @Deprecated
  25. public class LineShape
  26. extends AbstractShape
  27. {
  28. private EscherContainerRecord spContainer;
  29. private ObjRecord objRecord;
  30. /**
  31. * Creates the line shape from the highlevel user shape. All low level
  32. * records are created at this point.
  33. *
  34. * @param hssfShape The user model shape.
  35. * @param shapeId The identifier to use for this shape.
  36. */
  37. LineShape( HSSFSimpleShape hssfShape, int shapeId )
  38. {
  39. spContainer = createSpContainer(hssfShape, shapeId);
  40. objRecord = createObjRecord(hssfShape, shapeId);
  41. }
  42. /**
  43. * Creates the lowerlevel escher records for this shape.
  44. */
  45. private EscherContainerRecord createSpContainer(HSSFSimpleShape hssfShape, int shapeId)
  46. {
  47. HSSFShape shape = hssfShape;
  48. EscherContainerRecord spContainer = new EscherContainerRecord();
  49. EscherSpRecord sp = new EscherSpRecord();
  50. EscherOptRecord opt = new EscherOptRecord();
  51. EscherRecord anchor = new EscherClientAnchorRecord();
  52. EscherClientDataRecord clientData = new EscherClientDataRecord();
  53. spContainer.setRecordId( EscherContainerRecord.SP_CONTAINER );
  54. spContainer.setOptions( (short) 0x000F );
  55. sp.setRecordId( EscherSpRecord.RECORD_ID );
  56. sp.setOptions( (short) ( (EscherAggregate.ST_LINE << 4) | 0x2 ) );
  57. sp.setShapeId( shapeId );
  58. sp.setFlags( EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE );
  59. opt.setRecordId( EscherOptRecord.RECORD_ID );
  60. opt.addEscherProperty( new EscherShapePathProperty( EscherProperties.GEOMETRY__SHAPEPATH, EscherShapePathProperty.COMPLEX ) );
  61. opt.addEscherProperty( new EscherBoolProperty( EscherProperties.LINESTYLE__NOLINEDRAWDASH, 1048592 ) );
  62. addStandardOptions(shape, opt);
  63. HSSFAnchor userAnchor = shape.getAnchor();
  64. if (userAnchor.isHorizontallyFlipped())
  65. sp.setFlags(sp.getFlags() | EscherSpRecord.FLAG_FLIPHORIZ);
  66. if (userAnchor.isVerticallyFlipped())
  67. sp.setFlags(sp.getFlags() | EscherSpRecord.FLAG_FLIPVERT);
  68. anchor = createAnchor(userAnchor);
  69. clientData.setRecordId( EscherClientDataRecord.RECORD_ID );
  70. clientData.setOptions( (short) 0x0000 );
  71. spContainer.addChildRecord(sp);
  72. spContainer.addChildRecord(opt);
  73. spContainer.addChildRecord(anchor);
  74. spContainer.addChildRecord(clientData);
  75. return spContainer;
  76. }
  77. /**
  78. * Creates the low level OBJ record for this shape.
  79. */
  80. private ObjRecord createObjRecord(HSSFShape hssfShape, int shapeId)
  81. {
  82. HSSFShape shape = hssfShape;
  83. ObjRecord obj = new ObjRecord();
  84. CommonObjectDataSubRecord c = new CommonObjectDataSubRecord();
  85. c.setObjectType((short) ((HSSFSimpleShape)shape).getShapeType());
  86. c.setObjectId( getCmoObjectId(shapeId) );
  87. c.setLocked(true);
  88. c.setPrintable(true);
  89. c.setAutofill(true);
  90. c.setAutoline(true);
  91. EndSubRecord e = new EndSubRecord();
  92. obj.addSubRecord(c);
  93. obj.addSubRecord(e);
  94. return obj;
  95. }
  96. public EscherContainerRecord getSpContainer()
  97. {
  98. return spContainer;
  99. }
  100. public ObjRecord getObjRecord()
  101. {
  102. return objRecord;
  103. }
  104. }