Пример #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 = shape.SpContainer.GetChildById(EscherSpRecord.RECORD_ID);

            if (hssfShape.Parent != null)
            {
                sp.Flags = sp.Flags | EscherSpRecord.FLAG_CHILD;
            }
            return(shape);
        }
Пример #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 = shape.SpContainer.GetChildById(EscherSpRecord.RECORD_ID);
     if (hssfShape.Parent!= null)
         sp.Flags=sp.Flags | EscherSpRecord.FLAG_CHILD;
     return shape;
 }