HSSFSimpleShape

Namespace: NPOI
We found 10 examples in language CSharp for this search. You will see 44 fragments of code.
        static void Main(string[] args)
        {
            InitializeWorkbook();

            ISheet sheet1 = hssfworkbook.CreateSheet("new sheet");
            ISheet sheet2 = hssfworkbook.CreateSheet("second sheet");
            ISheet sheet3 = hssfworkbook.CreateSheet("third sheet");
            ISheet sheet4 = hssfworkbook.CreateSheet("fourth sheet");

            // Draw stuff in them
            DrawSheet1(sheet1);
            DrawSheet2(sheet2);
            DrawSheet3(sheet3);
            DrawSheet4(sheet4, hssfworkbook);

            WriteToFile();
        }


        private static void DrawSheet1(ISheet sheet1)
        {
            // Create a row and size one of the cells reasonably large.
            IRow row = sheet1.CreateRow(2);
            row.Height = ((short)2800);
            row.CreateCell(1);
            sheet1.SetColumnWidth(2, 9000);

            // Create the Drawing patriarch.  This is the top level container for
            // all shapes.
            HSSFPatriarch patriarch = (HSSFPatriarch)sheet1.CreateDrawingPatriarch();

            // Draw some lines and an oval.
            DrawLinesToCenter(patriarch);
            DrawManyLines(patriarch);
            DrawOval(patriarch);
            DrawPolygon(patriarch);

            // Draw a rectangle.
            HSSFSimpleShape rect = patriarch.CreateSimpleShape(new HSSFClientAnchor(100, 100, 900, 200, (short)0, 0, (short)0, 0));
            rect.ShapeType = (HSSFSimpleShape.OBJECT_TYPE_RECTANGLE);
        }

        private static void DrawSheet2(ISheet sheet2)
        {
            // Create a row and size one of the cells reasonably large.
            IRow row = sheet2.CreateRow(2);
            row.CreateCell(1);
            row.HeightInPoints = 240;
            sheet2.SetColumnWidth(2, 9000);

            // Create the Drawing patriarch.  This is the top level container for
            // all shapes. This will clear out any existing shapes for that sheet.
            HSSFPatriarch patriarch = (HSSFPatriarch)sheet2.CreateDrawingPatriarch();

            // Draw a grid in one of the cells.
            DrawGrid(patriarch);
        }

        private static void DrawSheet3(ISheet sheet3)
        {
            // Create a row and size one of the cells reasonably large
            IRow row = sheet3.CreateRow(2);
            row.HeightInPoints = 140;
            row.CreateCell(1);
            sheet3.SetColumnWidth(2, 9000);

            // Create the Drawing patriarch.  This is the top level container for
            // all shapes. This will clear out any existing shapes for that sheet.
            HSSFPatriarch patriarch = (HSSFPatriarch)sheet3.CreateDrawingPatriarch();

            // Create a shape group.
            HSSFShapeGroup group = patriarch.CreateGroup(
                    new HSSFClientAnchor(0, 0, 900, 200, (short)2, 2, (short)2, 2));

            // Create a couple of lines in the group.
            HSSFSimpleShape shape1 = group.CreateShape(new HSSFChildAnchor(3, 3, 500, 500));
            shape1.ShapeType = (HSSFSimpleShape.OBJECT_TYPE_LINE);
            ((HSSFChildAnchor)shape1.Anchor).SetAnchor((short)3, 3, 500, 500);
            HSSFSimpleShape shape2 = group.CreateShape(new HSSFChildAnchor((short)1, 200, 400, 600));
            shape2.ShapeType = (HSSFSimpleShape.OBJECT_TYPE_LINE);

        }

        private static void DrawSheet4(ISheet sheet4, HSSFWorkbook wb)
        {
            // Create the Drawing patriarch.  This is the top level container for
            // all shapes. This will clear out any existing shapes for that sheet.
            HSSFPatriarch patriarch = (HSSFPatriarch)sheet4.CreateDrawingPatriarch();

            // Create a couple of textboxes
            HSSFTextbox textbox1 = (HSSFTextbox)patriarch.CreateTextbox(
                    new HSSFClientAnchor(0, 0, 0, 0, (short)1, 1, (short)2, 2));
            textbox1.String = new HSSFRichTextString("This is a test");
            HSSFTextbox textbox2 = (HSSFTextbox)patriarch.CreateTextbox(
                    new HSSFClientAnchor(0, 0, 900, 100, (short)3, 3, (short)3, 4));
            textbox2.String = new HSSFRichTextString("Woo");
            textbox2.SetFillColor(200, 0, 0);
            textbox2.LineStyle = LineStyle.DotGel;
             
            // Create third one with some fancy font styling.
            HSSFTextbox textbox3 = (HSSFTextbox)patriarch.CreateTextbox(
                    new HSSFClientAnchor(0, 0, 900, 100, (short)4, 4, (short)5, 4 + 1));
            IFont font = wb.CreateFont();
            font.IsItalic = true;
            font.Underline = FontUnderlineType.Double;
            HSSFRichTextString str = new HSSFRichTextString("Woo!!!");
            str.ApplyFont(2, 5, font);
            textbox3.String = str;
            textbox3.FillColor = 0x08000030;
            textbox3.LineStyle = LineStyle.None;  // no line around the textbox.
            textbox3.IsNoFill = true;    // make it transparent
        }

        private static void DrawOval(HSSFPatriarch patriarch)
        {
            // Create an oval and style to taste.
            HSSFClientAnchor a = new HSSFClientAnchor();
            a.SetAnchor((short)2, 2, 20, 20, (short)2, 2, 190, 80);
            HSSFSimpleShape s = patriarch.CreateSimpleShape(a);
            s.ShapeType = HSSFSimpleShape.OBJECT_TYPE_OVAL;
            s.SetLineStyleColor(10, 10, 10);
            s.SetFillColor(90, 10, 200);
            s.LineWidth = HSSFShape.LINEWIDTH_ONE_PT * 3;
            s.LineStyle = LineStyle.DotSys;
        }

        /// <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;
        }

        /// <summary>
        /// Creates an escher anchor record from a HSSFAnchor.
        /// </summary>
        /// <param name="userAnchor">The high level anchor to Convert.</param>
        /// <returns>An escher anchor record.</returns>
        protected virtual EscherRecord CreateAnchor(HSSFAnchor userAnchor)
        {
            return ConvertAnchor.CreateAnchor(userAnchor);
        }

        /// <summary>
        /// Add standard properties to the opt record.  These properties effect
        /// all records.
        /// </summary>
        /// <param name="shape">The user model shape.</param>
        /// <param name="opt">The opt record to Add the properties to.</param>
        /// <returns>The number of options Added.</returns>
        protected virtual int AddStandardOptions(HSSFShape shape, EscherOptRecord opt)
        {
            opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 0x080000));
            //        opt.AddEscherProperty( new EscherBoolProperty( EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 0x080008 ) );
            if (shape.IsNoFill)
            {
                // Wonderful... none of the spec's give any clue as to what these constants mean.
                opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.Fill__NOFillHITTEST, 0x00110000));
            }
            else
            {
                opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.Fill__NOFillHITTEST, 0x00010000));
            }
            opt.AddEscherProperty(new EscherRGBProperty(EscherProperties.Fill__FillCOLOR, shape.FillColor));
            opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.GROUPSHAPE__PRINT, 0x080000));
            opt.AddEscherProperty(new EscherRGBProperty(EscherProperties.LINESTYLE__COLOR, shape.LineStyleColor));
            int options = 5;
            if (shape.LineWidth != HSSFShape.LINEWIDTH_DEFAULT)
            {
                opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEWIDTH, shape.LineWidth));
                options++;
            }
            if (shape.LineStyle != LineStyle.Solid)
            {
                opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEDASHING, (int)shape.LineStyle));
                opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEENDCAPSTYLE, 0));
                if (shape.LineStyle == LineStyle.None)
                    opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x00080000));
                else
                    opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x00080008));
                options += 3;
            }
            opt.SortProperties();
            return options;   // # options Added
        }
        /**
     * Generate id for the CommonObjectDataSubRecord that stands behind this shape
     *
     * <p>
     *     Typically objectId starts with 1, is unique among all Obj record within the worksheet stream
     *     and increments by 1 for every new shape.
     *     For most shapes there is a straight relationship between shapeId (generated by DDF) and objectId:
     * </p>
     * <p>
     *     shapeId  is unique and starts with 1024, hence objectId can be derived as <code>shapeId-1024</code>.
     * </p>
     * <p>
     *     An exception from this rule is the CellComment shape whose objectId start with 1024.
     *      See {@link CommentShape#getCmoObjectId(int)}
     * </p>
     *
     *
     *
     * @param  shapeId   shape id as generated by drawing manager
     * @return objectId  object id that will be assigned to the Obj record
     */
        protected virtual int GetCmoObjectId(int shapeId)
        {
            return shapeId - 1024;
        }


        /**
         * HSSFShape tree bust be built correctly
         * Check file with such records structure:
         * -patriarch
         * --shape
         * --group
         * ---group
         * ----shape
         * ----shape
         * ---shape
         * ---group
         * ----shape
         * ----shape
         */
        [Test]
        public void TestDrawingGroups()
        {
            HSSFWorkbook wb = HSSFTestDataSamples.OpenSampleWorkbook("drawings.xls");
            HSSFSheet sheet = wb.GetSheet("groups") as HSSFSheet;
            HSSFPatriarch patriarch = sheet.DrawingPatriarch as HSSFPatriarch;
            Assert.AreEqual(patriarch.Children.Count, 2);
            HSSFShapeGroup group = (HSSFShapeGroup)patriarch.Children[1];
            Assert.AreEqual(3, group.Children.Count);
            HSSFShapeGroup group1 = (HSSFShapeGroup)group.Children[0];
            Assert.AreEqual(2, group1.Children.Count);
            group1 = (HSSFShapeGroup)group.Children[2];
            Assert.AreEqual(2, group1.Children.Count);
        }

        public void TestHSSFShapeCompatibility()
        {
            HSSFSimpleShape shape = new HSSFSimpleShape(null, new HSSFClientAnchor());
            shape.ShapeType=(HSSFSimpleShape.OBJECT_TYPE_LINE);
            Assert.AreEqual(0x08000040, shape.LineStyleColor);
            Assert.AreEqual(0x08000009, shape.FillColor);
            Assert.AreEqual(HSSFShape.LINEWIDTH_DEFAULT, shape.LineWidth);
            Assert.AreEqual(HSSFShape.LINESTYLE_SOLID, shape.LineStyle);
            Assert.IsFalse(shape.IsNoFill);

            AbstractShape sp = AbstractShape.CreateShape(shape, 1);
            EscherContainerRecord spContainer = sp.SpContainer;
            EscherOptRecord opt = spContainer.GetChildById(EscherOptRecord.RECORD_ID) as EscherOptRecord;

            Assert.AreEqual(7, opt.EscherProperties.Count);
            Assert.AreEqual(true,
                    ((EscherBoolProperty)opt.Lookup(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE)).IsTrue);
            Assert.AreEqual(0x00000004,
                    ((EscherSimpleProperty)opt.Lookup(EscherProperties.GEOMETRY__SHAPEPATH)).PropertyValue);
            Assert.AreEqual(0x08000009,
                    ((EscherSimpleProperty)opt.Lookup(EscherProperties.FILL__FILLCOLOR)).PropertyValue);
            Assert.AreEqual(true,
                    ((EscherBoolProperty)opt.Lookup(EscherProperties.FILL__NOFILLHITTEST)).IsTrue);
            Assert.AreEqual(0x08000040,
                    ((EscherSimpleProperty)opt.Lookup(EscherProperties.LINESTYLE__COLOR)).PropertyValue);
            Assert.AreEqual(true,
                    ((EscherBoolProperty)opt.Lookup(EscherProperties.LINESTYLE__NOLINEDRAWDASH)).IsTrue);
            Assert.AreEqual(true,
                    ((EscherBoolProperty)opt.Lookup(EscherProperties.GROUPSHAPE__PRINT)).IsTrue);
        }

        public void TestDefaultPictureSettings()
        {
            HSSFPicture picture = new HSSFPicture(null, new HSSFClientAnchor());
            Assert.AreEqual(picture.LineWidth, HSSFShape.LINEWIDTH_DEFAULT);
            Assert.AreEqual(picture.FillColor, HSSFShape.FILL__FILLCOLOR_DEFAULT);
            Assert.AreEqual(picture.LineStyle, HSSFShape.LINESTYLE_NONE);
            Assert.AreEqual(picture.LineStyleColor, HSSFShape.LINESTYLE__COLOR_DEFAULT);
            Assert.AreEqual(picture.IsNoFill, false);
            Assert.AreEqual(picture.PictureIndex, -1);//not Set yet
        }

        /**
         * No NullPointerException should appear
         */
        public void TestDefaultSettingsWithEmptyContainer()
        {
            EscherContainerRecord Container = new EscherContainerRecord();
            EscherOptRecord opt = new EscherOptRecord();
            opt.RecordId=(EscherOptRecord.RECORD_ID);
            Container.AddChildRecord(opt);
            ObjRecord obj = new ObjRecord();
            CommonObjectDataSubRecord cod = new CommonObjectDataSubRecord();
            cod.ObjectType= (CommonObjectType) (HSSFSimpleShape.OBJECT_TYPE_PICTURE);
            obj.AddSubRecord(cod);
            HSSFPicture picture = new HSSFPicture(Container, obj);

            Assert.AreEqual(picture.LineWidth, HSSFShape.LINEWIDTH_DEFAULT);
            Assert.AreEqual(picture.FillColor, HSSFShape.FILL__FILLCOLOR_DEFAULT);
            Assert.AreEqual(picture.LineStyle, HSSFShape.LINESTYLE_DEFAULT);
            Assert.AreEqual(picture.LineStyleColor, HSSFShape.LINESTYLE__COLOR_DEFAULT);
            Assert.AreEqual(picture.IsNoFill, HSSFShape.NO_FILL_DEFAULT);
            Assert.AreEqual(picture.PictureIndex, -1);//not Set yet
        }

        /**
         * create a rectangle, save the workbook, read back and verify that all shape properties are there
         */
        public void TestReadWriteRectangle()
        {

            HSSFWorkbook wb = new HSSFWorkbook();
            HSSFSheet sheet = wb.CreateSheet() as HSSFSheet;

            HSSFPatriarch drawing = sheet.CreateDrawingPatriarch() as HSSFPatriarch;
            HSSFClientAnchor anchor = new HSSFClientAnchor(10, 10, 50, 50, (short)2, 2, (short)4, 4);
            anchor.AnchorType = (AnchorType)(2);
            Assert.AreEqual(anchor.AnchorType, 2);

            HSSFSimpleShape rectangle = drawing.CreateSimpleShape(anchor);
            rectangle.ShapeType=(HSSFSimpleShape.OBJECT_TYPE_RECTANGLE);
            rectangle.LineWidth=(10000);
            rectangle.FillColor=(777);
            Assert.AreEqual(rectangle.FillColor, 777);
            Assert.AreEqual(10000, rectangle.LineWidth);
            rectangle.LineStyle= (LineStyle)(10);
            Assert.AreEqual(10, rectangle.LineStyle);
            Assert.AreEqual(rectangle.WrapText, HSSFSimpleShape.WRAP_SQUARE);
            rectangle.LineStyleColor=(1111);
            rectangle.IsNoFill=(true);
            rectangle.WrapText=(HSSFSimpleShape.WRAP_NONE);
            rectangle.String=(new HSSFRichTextString("teeeest"));
            Assert.AreEqual(rectangle.LineStyleColor, 1111);
            Assert.AreEqual(((EscherSimpleProperty)((EscherOptRecord)HSSFTestHelper.GetEscherContainer(rectangle).GetChildById(EscherOptRecord.RECORD_ID))
                    .Lookup(EscherProperties.TEXT__TEXTID)).PropertyValue, "teeeest".GetHashCode());
            Assert.AreEqual(rectangle.IsNoFill, true);
            Assert.AreEqual(rectangle.WrapText, HSSFSimpleShape.WRAP_NONE);
            Assert.AreEqual(rectangle.String.String, "teeeest");

            wb = HSSFTestDataSamples.WriteOutAndReadBack(wb);
            sheet = wb.GetSheetAt(0) as HSSFSheet;
            drawing = sheet.DrawingPatriarch as HSSFPatriarch;
            Assert.AreEqual(1, drawing.Children.Count);

            HSSFSimpleShape rectangle2 =
                    (HSSFSimpleShape)drawing.Children[0];
            Assert.AreEqual(HSSFSimpleShape.OBJECT_TYPE_RECTANGLE,
                    rectangle2.ShapeType);
            Assert.AreEqual(10000, rectangle2.LineWidth);
            Assert.AreEqual(10, (int)rectangle2.LineStyle);
            Assert.AreEqual(anchor, rectangle2.Anchor);
            Assert.AreEqual(rectangle2.LineStyleColor, 1111);
            Assert.AreEqual(rectangle2.FillColor, 777);
            Assert.AreEqual(rectangle2.IsNoFill, true);
            Assert.AreEqual(rectangle2.String.String, "teeeest");
            Assert.AreEqual(rectangle.WrapText, HSSFSimpleShape.WRAP_NONE);

            rectangle2.FillColor=(3333);
            rectangle2.LineStyle = (LineStyle)(9);
            rectangle2.LineStyleColor=(4444);
            rectangle2.IsNoFill=(false);
            rectangle2.LineWidth=(77);
            rectangle2.Anchor.Dx1=2;
            rectangle2.Anchor.Dx2=3;
            rectangle2.Anchor.Dy1=(4);
            rectangle2.Anchor.Dy2=(5);
            rectangle.WrapText=(HSSFSimpleShape.WRAP_BY_POINTS);
            rectangle2.String=(new HSSFRichTextString("test22"));

            wb = HSSFTestDataSamples.WriteOutAndReadBack(wb);
            sheet = wb.GetSheetAt(0) as HSSFSheet;
            drawing = sheet.DrawingPatriarch as HSSFPatriarch;
            Assert.AreEqual(1, drawing.Children.Count);
            rectangle2 = (HSSFSimpleShape)drawing.Children[0];
            Assert.AreEqual(HSSFSimpleShape.OBJECT_TYPE_RECTANGLE, rectangle2.ShapeType);
            Assert.AreEqual(rectangle.WrapText, HSSFSimpleShape.WRAP_BY_POINTS);
            Assert.AreEqual(77, rectangle2.LineWidth);
            Assert.AreEqual(9, rectangle2.LineStyle);
            Assert.AreEqual(rectangle2.LineStyleColor, 4444);
            Assert.AreEqual(rectangle2.FillColor, 3333);
            Assert.AreEqual(rectangle2.Anchor.Dx1, 2);
            Assert.AreEqual(rectangle2.Anchor.Dx2, 3);
            Assert.AreEqual(rectangle2.Anchor.Dy1, 4);
            Assert.AreEqual(rectangle2.Anchor.Dy2, 5);
            Assert.AreEqual(rectangle2.IsNoFill, false);
            Assert.AreEqual(rectangle2.String.String, "test22");

            HSSFSimpleShape rect3 = drawing.CreateSimpleShape(new HSSFClientAnchor());
            rect3.ShapeType=(HSSFSimpleShape.OBJECT_TYPE_RECTANGLE);
            wb = HSSFTestDataSamples.WriteOutAndReadBack(wb);

            drawing = (wb.GetSheetAt(0) as HSSFSheet).DrawingPatriarch as HSSFPatriarch;
            Assert.AreEqual(drawing.Children.Count, 2);
        }

        public void TestReadExistingImage()
        {
            HSSFWorkbook wb = HSSFTestDataSamples.OpenSampleWorkbook("drawings.xls");
            HSSFSheet sheet = wb.GetSheet("pictures") as HSSFSheet;
            HSSFPatriarch Drawing = sheet.DrawingPatriarch as HSSFPatriarch;
            Assert.AreEqual(1, Drawing.Children.Count);
            HSSFPicture picture = (HSSFPicture)Drawing.Children[0];

            Assert.AreEqual(picture.PictureIndex, 2);
            Assert.AreEqual(picture.LineStyleColor, HSSFShape.LINESTYLE__COLOR_DEFAULT);
            Assert.AreEqual(picture.FillColor, 0x5DC943);
            Assert.AreEqual(picture.LineWidth, HSSFShape.LINEWIDTH_DEFAULT);
            Assert.AreEqual(picture.LineStyle, HSSFShape.LINESTYLE_DEFAULT);
            Assert.AreEqual(picture.IsNoFill, false);

            picture.PictureIndex=(2);
            Assert.AreEqual(picture.PictureIndex, 2);
        }

        /// <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;
        }

        /// <summary>
        /// Creates an escher anchor record from a HSSFAnchor.
        /// </summary>
        /// <param name="userAnchor">The high level anchor to Convert.</param>
        /// <returns>An escher anchor record.</returns>
        protected virtual EscherRecord CreateAnchor(HSSFAnchor userAnchor)
        {
            return ConvertAnchor.CreateAnchor(userAnchor);
        }

        /// <summary>
        /// Add standard properties to the opt record.  These properties effect
        /// all records.
        /// </summary>
        /// <param name="shape">The user model shape.</param>
        /// <param name="opt">The opt record to Add the properties to.</param>
        /// <returns>The number of options Added.</returns>
        protected virtual int AddStandardOptions(HSSFShape shape, EscherOptRecord opt)
        {
            opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 0x080000));
            //        opt.AddEscherProperty( new EscherBoolProperty( EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 0x080008 ) );
            if (shape.IsNoFill)
            {
                // Wonderful... none of the spec's give any clue as to what these constants mean.
                opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.Fill__NOFillHITTEST, 0x00110000));
            }
            else
            {
                opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.Fill__NOFillHITTEST, 0x00010000));
            }
            opt.AddEscherProperty(new EscherRGBProperty(EscherProperties.Fill__FillCOLOR, shape.FillColor));
            opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.GROUPSHAPE__PRINT, 0x080000));
            opt.AddEscherProperty(new EscherRGBProperty(EscherProperties.LINESTYLE__COLOR, shape.LineStyleColor));
            int options = 5;
            if (shape.LineWidth != HSSFShape.LINEWIDTH_DEFAULT)
            {
                opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEWIDTH, shape.LineWidth));
                options++;
            }
            if (shape.LineStyle != LineStyle.Solid)
            {
                opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEDASHING, (int)shape.LineStyle));
                opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEENDCAPSTYLE, 0));
                if (shape.LineStyle == LineStyle.None)
                    opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x00080000));
                else
                    opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x00080008));
                options += 3;
            }
            opt.SortProperties();
            return options;   // # options Added
        }
        /**
     * Generate id for the CommonObjectDataSubRecord that stands behind this shape
     *
     * <p>
     *     Typically objectId starts with 1, is unique among all Obj record within the worksheet stream
     *     and increments by 1 for every new shape.
     *     For most shapes there is a straight relationship between shapeId (generated by DDF) and objectId:
     * </p>
     * <p>
     *     shapeId  is unique and starts with 1024, hence objectId can be derived as <code>shapeId-1024</code>.
     * </p>
     * <p>
     *     An exception from this rule is the CellComment shape whose objectId start with 1024.
     *      See {@link CommentShape#getCmoObjectId(int)}
     * </p>
     *
     *
     *
     * @param  shapeId   shape id as generated by drawing manager
     * @return objectId  object id that will be assigned to the Obj record
     */
        protected virtual int GetCmoObjectId(int shapeId)
        {
            return shapeId - 1024;
        }

        /// <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;
        }

        /// <summary>
        /// Creates an escher anchor record from a HSSFAnchor.
        /// </summary>
        /// <param name="userAnchor">The high level anchor to Convert.</param>
        /// <returns>An escher anchor record.</returns>
        protected virtual EscherRecord CreateAnchor(HSSFAnchor userAnchor)
        {
            return ConvertAnchor.CreateAnchor(userAnchor);
        }

        /// <summary>
        /// Add standard properties to the opt record.  These properties effect
        /// all records.
        /// </summary>
        /// <param name="shape">The user model shape.</param>
        /// <param name="opt">The opt record to Add the properties to.</param>
        /// <returns>The number of options Added.</returns>
        protected virtual int AddStandardOptions(HSSFShape shape, EscherOptRecord opt)
        {
            opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 0x080000));
            //        opt.AddEscherProperty( new EscherBoolProperty( EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 0x080008 ) );
            if (shape.IsNoFill)
            {
                // Wonderful... none of the spec's give any clue as to what these constants mean.
                opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.Fill__NOFillHITTEST, 0x00110000));
            }
            else
            {
                opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.Fill__NOFillHITTEST, 0x00010000));
            }
            opt.AddEscherProperty(new EscherRGBProperty(EscherProperties.Fill__FillCOLOR, shape.FillColor));
            opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.GROUPSHAPE__PRINT, 0x080000));
            opt.AddEscherProperty(new EscherRGBProperty(EscherProperties.LINESTYLE__COLOR, shape.LineStyleColor));
            int options = 5;
            if (shape.LineWidth != HSSFShape.LINEWIDTH_DEFAULT)
            {
                opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEWIDTH, shape.LineWidth));
                options++;
            }
            if (shape.LineStyle != LineStyle.Solid)
            {
                opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEDASHING, (int)shape.LineStyle));
                opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEENDCAPSTYLE, 0));
                if (shape.LineStyle == LineStyle.None)
                    opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x00080000));
                else
                    opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x00080008));
                options += 3;
            }
            opt.SortProperties();
            return options;   // # options Added
        }
        /**
     * Generate id for the CommonObjectDataSubRecord that stands behind this shape
     *
     * <p>
     *     Typically objectId starts with 1, is unique among all Obj record within the worksheet stream
     *     and increments by 1 for every new shape.
     *     For most shapes there is a straight relationship between shapeId (generated by DDF) and objectId:
     * </p>
     * <p>
     *     shapeId  is unique and starts with 1024, hence objectId can be derived as <code>shapeId-1024</code>.
     * </p>
     * <p>
     *     An exception from this rule is the CellComment shape whose objectId start with 1024.
     *      See {@link CommentShape#getCmoObjectId(int)}
     * </p>
     *
     *
     *
     * @param  shapeId   shape id as generated by drawing manager
     * @return objectId  object id that will be assigned to the Obj record
     */
        protected virtual int GetCmoObjectId(int shapeId)
        {
            return shapeId - 1024;
        }

        /// <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;
        }

        /// <summary>
        /// Creates an escher anchor record from a HSSFAnchor.
        /// </summary>
        /// <param name="userAnchor">The high level anchor to Convert.</param>
        /// <returns>An escher anchor record.</returns>
        protected virtual EscherRecord CreateAnchor(HSSFAnchor userAnchor)
        {
            return ConvertAnchor.CreateAnchor(userAnchor);
        }

        /// <summary>
        /// Add standard properties to the opt record.  These properties effect
        /// all records.
        /// </summary>
        /// <param name="shape">The user model shape.</param>
        /// <param name="opt">The opt record to Add the properties to.</param>
        /// <returns>The number of options Added.</returns>
        protected virtual int AddStandardOptions(HSSFShape shape, EscherOptRecord opt)
        {
            opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 0x080000));
            //        opt.AddEscherProperty( new EscherBoolProperty( EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 0x080008 ) );
            if (shape.IsNoFill)
            {
                // Wonderful... none of the spec's give any clue as to what these constants mean.
                opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.FILL__NOFILLHITTEST, 0x00110000));
            }
            else
            {
                opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.FILL__NOFILLHITTEST, 0x00010000));
            }
            opt.AddEscherProperty(new EscherRGBProperty(EscherProperties.FILL__FILLCOLOR, shape.FillColor));
            opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.GROUPSHAPE__PRINT, 0x080000));
            opt.AddEscherProperty(new EscherRGBProperty(EscherProperties.LINESTYLE__COLOR, shape.LineStyleColor));
            int options = 5;
            if (shape.LineWidth != HSSFShape.LINEWIDTH_DEFAULT)
            {
                opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEWIDTH, shape.LineWidth));
                options++;
            }
            if (shape.LineStyle != LineStyle.Solid)
            {
                opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEDASHING, (int)shape.LineStyle));
                opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEENDCAPSTYLE, 0));
                if (shape.LineStyle == LineStyle.None)
                    opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x00080000));
                else
                    opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x00080008));
                options += 3;
            }
            opt.SortProperties();
            return options;   // # options Added
        }
        /// <summary>
        ///  Generate id for the CommonObjectDataSubRecord that stands behind this shape
        /// </summary>
        /// <param name="shapeId">shape id as generated by drawing manager</param>
        /// <returns>object id that will be assigned to the Obj record</returns>
        protected virtual int GetCmoObjectId(int shapeId)
        {
            //Typically objectId starts with 1, is unique among all Obj record within the worksheet stream
            //and increments by 1 for every new shape.
            //For most shapes there is a straight relationship between shapeId (generated by DDF) and objectId:
            //shapeId  is unique and starts with 1024, hence objectId can be derived as <code>shapeId-1024</code>.
            return shapeId - 1024;
        }

        /// <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;
        }

        /// <summary>
        /// Creates an escher anchor record from a HSSFAnchor.
        /// </summary>
        /// <param name="userAnchor">The high level anchor to Convert.</param>
        /// <returns>An escher anchor record.</returns>
        protected virtual EscherRecord CreateAnchor(HSSFAnchor userAnchor)
        {
            return ConvertAnchor.CreateAnchor(userAnchor);
        }

        /// <summary>
        /// Add standard properties to the opt record.  These properties effect
        /// all records.
        /// </summary>
        /// <param name="shape">The user model shape.</param>
        /// <param name="opt">The opt record to Add the properties to.</param>
        /// <returns>The number of options Added.</returns>
        protected virtual int AddStandardOptions(HSSFShape shape, EscherOptRecord opt)
        {
            opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 0x080000));
            //        opt.AddEscherProperty( new EscherBoolProperty( EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 0x080008 ) );
            if (shape.IsNoFill)
            {
                // Wonderful... none of the spec's give any clue as to what these constants mean.
                opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.FILL__NOFILLHITTEST, 0x00110000));
            }
            else
            {
                opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.FILL__NOFILLHITTEST, 0x00010000));
            }
            opt.AddEscherProperty(new EscherRGBProperty(EscherProperties.FILL__FILLCOLOR, shape.FillColor));
            opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.GROUPSHAPE__PRINT, 0x080000));
            opt.AddEscherProperty(new EscherRGBProperty(EscherProperties.LINESTYLE__COLOR, shape.LineStyleColor));
            int options = 5;
            if (shape.LineWidth != HSSFShape.LINEWIDTH_DEFAULT)
            {
                opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEWIDTH, shape.LineWidth));
                options++;
            }
            if (shape.LineStyle != LineStyle.Solid)
            {
                opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEDASHING, (int)shape.LineStyle));
                opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEENDCAPSTYLE, 0));
                if (shape.LineStyle == LineStyle.None)
                    opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x00080000));
                else
                    opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x00080008));
                options += 3;
            }
            opt.SortProperties();
            return options;   // # options Added
        }
        /// <summary>
        ///  Generate id for the CommonObjectDataSubRecord that stands behind this shape
        /// </summary>
        /// <param name="shapeId">shape id as generated by drawing manager</param>
        /// <returns>object id that will be assigned to the Obj record</returns>
        protected virtual int GetCmoObjectId(int shapeId)
        {
            //Typically objectId starts with 1, is unique among all Obj record within the worksheet stream
            //and increments by 1 for every new shape.
            //For most shapes there is a straight relationship between shapeId (generated by DDF) and objectId:
            //shapeId  is unique and starts with 1024, hence objectId can be derived as <code>shapeId-1024</code>.
            return shapeId - 1024;
        }

        /// <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;
        }

        /// <summary>
        /// Creates an escher anchor record from a HSSFAnchor.
        /// </summary>
        /// <param name="userAnchor">The high level anchor to Convert.</param>
        /// <returns>An escher anchor record.</returns>
        protected virtual EscherRecord CreateAnchor(HSSFAnchor userAnchor)
        {
            return ConvertAnchor.CreateAnchor(userAnchor);
        }

        /// <summary>
        /// Add standard properties to the opt record.  These properties effect
        /// all records.
        /// </summary>
        /// <param name="shape">The user model shape.</param>
        /// <param name="opt">The opt record to Add the properties to.</param>
        /// <returns>The number of options Added.</returns>
        protected virtual int AddStandardOptions(HSSFShape shape, EscherOptRecord opt)
        {
            opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 0x080000));
            //        opt.AddEscherProperty( new EscherBoolProperty( EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 0x080008 ) );
            if (shape.IsNoFill)
            {
                // Wonderful... none of the spec's give any clue as to what these constants mean.
                opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.Fill__NOFillHITTEST, 0x00110000));
            }
            else
            {
                opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.Fill__NOFillHITTEST, 0x00010000));
            }
            opt.AddEscherProperty(new EscherRGBProperty(EscherProperties.Fill__FillCOLOR, shape.FillColor));
            opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.GROUPSHAPE__PRINT, 0x080000));
            opt.AddEscherProperty(new EscherRGBProperty(EscherProperties.LINESTYLE__COLOR, shape.LineStyleColor));
            int options = 5;
            if (shape.LineWidth != HSSFShape.LINEWIDTH_DEFAULT)
            {
                opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEWIDTH, shape.LineWidth));
                options++;
            }
            if (shape.LineStyle != LineStyle.Solid)
            {
                opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEDASHING, (int)shape.LineStyle));
                opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEENDCAPSTYLE, 0));
                if (shape.LineStyle == LineStyle.None)
                    opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x00080000));
                else
                    opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x00080008));
                options += 3;
            }
            opt.SortProperties();
            return options;   // # options Added
        }
        /**
     * Generate id for the CommonObjectDataSubRecord that stands behind this shape
     *
     * <p>
     *     Typically objectId starts with 1, is unique among all Obj record within the worksheet stream
     *     and increments by 1 for every new shape.
     *     For most shapes there is a straight relationship between shapeId (generated by DDF) and objectId:
     * </p>
     * <p>
     *     shapeId  is unique and starts with 1024, hence objectId can be derived as <code>shapeId-1024</code>.
     * </p>
     * <p>
     *     An exception from this rule is the CellComment shape whose objectId start with 1024.
     *      See {@link CommentShape#getCmoObjectId(int)}
     * </p>
     *
     *
     *
     * @param  shapeId   shape id as generated by drawing manager
     * @return objectId  object id that will be assigned to the Obj record
     */
        protected virtual int GetCmoObjectId(int shapeId)
        {
            return shapeId - 1024;
        }

        /// <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;
        }

        /// <summary>
        /// Creates an escher anchor record from a HSSFAnchor.
        /// </summary>
        /// <param name="userAnchor">The high level anchor to Convert.</param>
        /// <returns>An escher anchor record.</returns>
        protected virtual EscherRecord CreateAnchor(HSSFAnchor userAnchor)
        {
            return ConvertAnchor.CreateAnchor(userAnchor);
        }

        /// <summary>
        /// Add standard properties to the opt record.  These properties effect
        /// all records.
        /// </summary>
        /// <param name="shape">The user model shape.</param>
        /// <param name="opt">The opt record to Add the properties to.</param>
        /// <returns>The number of options Added.</returns>
        protected virtual int AddStandardOptions(HSSFShape shape, EscherOptRecord opt)
        {
            opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 0x080000));
            //        opt.AddEscherProperty( new EscherBoolProperty( EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 0x080008 ) );
            if (shape.IsNoFill)
            {
                // Wonderful... none of the spec's give any clue as to what these constants mean.
                opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.FILL__NOFILLHITTEST, 0x00110000));
            }
            else
            {
                opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.FILL__NOFILLHITTEST, 0x00010000));
            }
            opt.AddEscherProperty(new EscherRGBProperty(EscherProperties.FILL__FILLCOLOR, shape.FillColor));
            opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.GROUPSHAPE__PRINT, 0x080000));
            opt.AddEscherProperty(new EscherRGBProperty(EscherProperties.LINESTYLE__COLOR, shape.LineStyleColor));
            int options = 5;
            if (shape.LineWidth != HSSFShape.LINEWIDTH_DEFAULT)
            {
                opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEWIDTH, shape.LineWidth));
                options++;
            }
            if (shape.LineStyle != LineStyle.Solid)
            {
                opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEDASHING, (int)shape.LineStyle));
                opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEENDCAPSTYLE, 0));
                if (shape.LineStyle == LineStyle.None)
                    opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x00080000));
                else
                    opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x00080008));
                options += 3;
            }
            opt.SortProperties();
            return options;   // # options Added
        }
        /// <summary>
        ///  Generate id for the CommonObjectDataSubRecord that stands behind this shape
        /// </summary>
        /// <param name="shapeId">shape id as generated by drawing manager</param>
        /// <returns>object id that will be assigned to the Obj record</returns>
        protected virtual int GetCmoObjectId(int shapeId)
        {
            //Typically objectId starts with 1, is unique among all Obj record within the worksheet stream
            //and increments by 1 for every new shape.
            //For most shapes there is a straight relationship between shapeId (generated by DDF) and objectId:
            //shapeId  is unique and starts with 1024, hence objectId can be derived as <code>shapeId-1024</code>.
            return shapeId - 1024;
        }

        /// <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;
        }

        /// <summary>
        /// Creates an escher anchor record from a HSSFAnchor.
        /// </summary>
        /// <param name="userAnchor">The high level anchor to Convert.</param>
        /// <returns>An escher anchor record.</returns>
        protected virtual EscherRecord CreateAnchor(HSSFAnchor userAnchor)
        {
            return ConvertAnchor.CreateAnchor(userAnchor);
        }

        /// <summary>
        /// Add standard properties to the opt record.  These properties effect
        /// all records.
        /// </summary>
        /// <param name="shape">The user model shape.</param>
        /// <param name="opt">The opt record to Add the properties to.</param>
        /// <returns>The number of options Added.</returns>
        protected virtual int AddStandardOptions(HSSFShape shape, EscherOptRecord opt)
        {
            opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 0x080000));
            //        opt.AddEscherProperty( new EscherBoolProperty( EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 0x080008 ) );
            if (shape.IsNoFill)
            {
                // Wonderful... none of the spec's give any clue as to what these constants mean.
                opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.FILL__NOFILLHITTEST, 0x00110000));
            }
            else
            {
                opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.FILL__NOFILLHITTEST, 0x00010000));
            }
            opt.AddEscherProperty(new EscherRGBProperty(EscherProperties.FILL__FILLCOLOR, shape.FillColor));
            opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.GROUPSHAPE__PRINT, 0x080000));
            opt.AddEscherProperty(new EscherRGBProperty(EscherProperties.LINESTYLE__COLOR, shape.LineStyleColor));
            int options = 5;
            if (shape.LineWidth != HSSFShape.LINEWIDTH_DEFAULT)
            {
                opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEWIDTH, shape.LineWidth));
                options++;
            }
            if (shape.LineStyle != LineStyle.Solid)
            {
                opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEDASHING, (int)shape.LineStyle));
                opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEENDCAPSTYLE, 0));
                if (shape.LineStyle == LineStyle.None)
                    opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x00080000));
                else
                    opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x00080008));
                options += 3;
            }
            opt.SortProperties();
            return options;   // # options Added
        }
        /// <summary>
        ///  Generate id for the CommonObjectDataSubRecord that stands behind this shape
        /// </summary>
        /// <param name="shapeId">shape id as generated by drawing manager</param>
        /// <returns>object id that will be assigned to the Obj record</returns>
        protected virtual int GetCmoObjectId(int shapeId)
        {
            //Typically objectId starts with 1, is unique among all Obj record within the worksheet stream
            //and increments by 1 for every new shape.
            //For most shapes there is a straight relationship between shapeId (generated by DDF) and objectId:
            //shapeId  is unique and starts with 1024, hence objectId can be derived as <code>shapeId-1024</code>.
            return shapeId - 1024;
        }

NPOI.HSSF.UserModel.HSSFSimpleShape : HSSFShape

Fields :

public static Int16 OBJECT_TYPE_LINE
public static Int16 OBJECT_TYPE_RECTANGLE
public static Int16 OBJECT_TYPE_OVAL
public static Int16 OBJECT_TYPE_ARC
public static Int16 OBJECT_TYPE_PICTURE
public static Int16 OBJECT_TYPE_COMBO_BOX
public static Int16 OBJECT_TYPE_COMMENT
public static Int16 OBJECT_TYPE_MICROSOFT_OFFICE_DRAWING
public static Int32 WRAP_SQUARE
public static Int32 WRAP_BY_POINTS
public static Int32 WRAP_NONE

Constructors :

public HSSFSimpleShape(EscherContainerRecord spContainer = , ObjRecord objRecord = , TextObjectRecord textObjectRecord = )
public HSSFSimpleShape(EscherContainerRecord spContainer = , ObjRecord objRecord = )
public HSSFSimpleShape(HSSFShape parent = , HSSFAnchor anchor = )

Methods :

public Int32 get_ShapeType()
public Void set_ShapeType(Int32 value = )
public Int32 get_WrapText()
public Void set_WrapText(Int32 value = )
public IRichTextString get_String()
public Void set_String(IRichTextString value = )
public Boolean get_FlipVertical()
public Void set_FlipVertical(Boolean value = )
public Boolean get_FlipHorizontal()
public Void set_FlipHorizontal(Boolean value = )
public Int32 get_ShapeId()
public Void set_ShapeId(Int32 value = )
public HSSFShape get_Parent()
public Void set_Parent(HSSFShape value = )
public HSSFAnchor get_Anchor()
public Void set_Anchor(HSSFAnchor value = )
public Int32 get_LineStyleColor()
public Void set_LineStyleColor(Int32 value = )
public Void SetLineStyleColor(Int32 red = , Int32 green = , Int32 blue = )
public Int32 get_FillColor()
public Void set_FillColor(Int32 value = )
public Void SetFillColor(Int32 red = , Int32 green = , Int32 blue = )
public Int32 get_LineWidth()
public Void set_LineWidth(Int32 value = )
public LineStyle get_LineStyle()
public Void set_LineStyle(LineStyle value = )
public Boolean get_IsNoFill()
public Void set_IsNoFill(Boolean value = )
public Boolean get_IsFlipVertical()
public Void set_IsFlipVertical(Boolean value = )
public Boolean get_IsFlipHorizontal()
public Void set_IsFlipHorizontal(Boolean value = )
public Int32 get_RotationDegree()
public Void set_RotationDegree(Int32 value = )
public Int32 get_CountOfAllChildren()
public HSSFPatriarch get_Patriarch()
public Void set_Patriarch(HSSFPatriarch value = )
public Type GetType()
public String ToString()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()