Exemplo n.º 1
0
        /// <summary>
        /// Create a new shape object used to Create the escher records.
        /// </summary>
        /// <param name="hssfShape">The simple shape this Is based on.</param>
        /// <param name="shapeId">The shape id.</param>
        /// <returns></returns>
        public static AbstractShape CreateShape(HSSFShape hssfShape, int shapeId)
        {
            AbstractShape shape;

            if (hssfShape is HSSFComment)
            {
                shape = new CommentShape((HSSFComment)hssfShape, shapeId);
            }
            else if (hssfShape is HSSFTextbox)
            {
                shape = new TextboxShape((HSSFTextbox)hssfShape, shapeId);
            }
            else if (hssfShape is HSSFPolygon)
            {
                shape = new PolygonShape((HSSFPolygon)hssfShape, shapeId);
            }
            else if (hssfShape is HSSFSimpleShape)
            {
                HSSFSimpleShape simpleShape = (HSSFSimpleShape)hssfShape;
                switch (simpleShape.ShapeType)
                {
                case HSSFSimpleShape.OBJECT_TYPE_PICTURE:
                    shape = new PictureShape(simpleShape, shapeId);
                    break;

                case HSSFSimpleShape.OBJECT_TYPE_LINE:
                    shape = new LineShape(simpleShape, shapeId);
                    break;

                case HSSFSimpleShape.OBJECT_TYPE_OVAL:
                case HSSFSimpleShape.OBJECT_TYPE_RECTANGLE:
                    shape = new SimpleFilledShape(simpleShape, shapeId);
                    break;

                case HSSFSimpleShape.OBJECT_TYPE_COMBO_BOX:
                    shape = new ComboboxShape(simpleShape, shapeId);
                    break;

                default:
                    throw new ArgumentException("Do not know how to handle this type of shape");
                }
            }
            else
            {
                throw new ArgumentException("Unknown shape type");
            }
            EscherSpRecord sp = (EscherSpRecord)shape.SpContainer.GetChildById(EscherSpRecord.RECORD_ID);

            if (hssfShape.Parent != null)
            {
                sp.Flags = sp.Flags | EscherSpRecord.FLAG_CHILD;
            }
            return(shape);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Create a new shape object used to Create the escher records.
 /// </summary>
 /// <param name="hssfShape">The simple shape this Is based on.</param>
 /// <param name="shapeId">The shape id.</param>
 /// <returns></returns>
 public static AbstractShape CreateShape(HSSFShape hssfShape, int shapeId)
 {
     AbstractShape shape;
     if (hssfShape is HSSFComment)
     {
         shape = new CommentShape((HSSFComment)hssfShape, shapeId);
     }
     else if (hssfShape is HSSFTextbox)
     {
         shape = new TextboxShape((HSSFTextbox)hssfShape, shapeId);
     }
     else if (hssfShape is HSSFPolygon)
     {
         shape = new PolygonShape((HSSFPolygon)hssfShape, shapeId);
     }
     else if (hssfShape is HSSFSimpleShape)
     {
         HSSFSimpleShape simpleShape = (HSSFSimpleShape)hssfShape;
         switch (simpleShape.ShapeType)
         {
             case HSSFSimpleShape.OBJECT_TYPE_PICTURE:
                 shape = new PictureShape(simpleShape, shapeId);
                 break;
             case HSSFSimpleShape.OBJECT_TYPE_LINE:
                 shape = new LineShape(simpleShape, shapeId);
                 break;
             case HSSFSimpleShape.OBJECT_TYPE_OVAL:
             case HSSFSimpleShape.OBJECT_TYPE_RECTANGLE:
                 shape = new SimpleFilledShape(simpleShape, shapeId);
                 break;
             case HSSFSimpleShape.OBJECT_TYPE_COMBO_BOX:
                 shape = new ComboboxShape(simpleShape, shapeId);
                 break;
             default:
                 throw new ArgumentException("Do not know how to handle this type of shape");
         }
     }
     else
     {
         throw new ArgumentException("Unknown shape type");
     }
     EscherSpRecord sp = (EscherSpRecord)shape.SpContainer.GetChildById(EscherSpRecord.RECORD_ID);
     if (hssfShape.Parent!= null)
         sp.Flags=sp.Flags | EscherSpRecord.FLAG_CHILD;
     return shape;
 }
Exemplo n.º 3
0
        public void TestShapeId()
        {

            HSSFClientAnchor anchor = new HSSFClientAnchor();
            AbstractShape shape;
            CommonObjectDataSubRecord cmo;

            shape = new TextboxShape(new HSSFTextbox(null, anchor), 1025);
            cmo = (CommonObjectDataSubRecord)shape.ObjRecord.SubRecords[(0)];
            Assert.AreEqual(1, cmo.ObjectId);

            shape = new PictureShape(new HSSFPicture(null, anchor), 1026);
            cmo = (CommonObjectDataSubRecord)shape.ObjRecord.SubRecords[(0)];
            Assert.AreEqual(2, cmo.ObjectId);

            shape = new CommentShape(new HSSFComment(null, anchor), 1027);
            cmo = (CommonObjectDataSubRecord)shape.ObjRecord.SubRecords[(0)];
            Assert.AreEqual(1027, cmo.ObjectId);
        }