Example #1
0
        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);
        }
        private void ConvertShapes(HSSFShapeContainer parent, EscherContainerRecord escherParent, Hashtable shapeToObj)
        {
            if (escherParent == null)
            {
                throw new ArgumentException("Parent record required");
            }

            IList shapes = parent.Children;

            for (IEnumerator iterator = shapes.GetEnumerator(); iterator.MoveNext();)
            {
                HSSFShape shape = (HSSFShape)iterator.Current;
                if (shape is HSSFShapeGroup)
                {
                    ConvertGroup((HSSFShapeGroup)shape, escherParent, shapeToObj);
                }
                else
                {
                    AbstractShape shapeModel = AbstractShape.CreateShape(
                        shape,
                        drawingManager.AllocateShapeId(drawingGroupId));
                    shapeToObj[FindClientData(shapeModel.SpContainer)] = shapeModel.ObjRecord;
                    if (shapeModel is TextboxShape)
                    {
                        EscherRecord escherTextbox = ((TextboxShape)shapeModel).EscherTextbox;
                        shapeToObj[escherTextbox] = ((TextboxShape)shapeModel).TextObjectRecord;
                        //                    escherParent.AddChildRecord(escherTextbox);

                        if (shapeModel is CommentShape)
                        {
                            CommentShape comment = (CommentShape)shapeModel;
                            tailRec.Add(comment.NoteRecord);
                        }
                    }
                    escherParent.AddChildRecord(shapeModel.SpContainer);
                }
            }
            //        drawingManager.newCluster( (short)1 );
            //        drawingManager.newCluster( (short)2 );
        }