Exemplo n.º 1
0
        /**
         * Creates the low level OBJ record for this shape.
         */
        //private ObjRecord CreateObjRecord(HSSFSimpleShape shape, int shapeId)
        //{
        //    ObjRecord obj = new ObjRecord();
        //    CommonObjectDataSubRecord c = new CommonObjectDataSubRecord();
        //    c.ObjectType = CommonObjectType.COMBO_BOX;
        //    c.ObjectId = shapeId;
        //    c.IsLocked = true;
        //    c.IsPrintable = false;
        //    c.IsAutoFill = true;
        //    c.IsAutoline = false;

        //    FtCblsSubRecord f = new FtCblsSubRecord();

        //    LbsDataSubRecord l = LbsDataSubRecord.CreateAutoFilterInstance();

        //    EndSubRecord e = new EndSubRecord();

        //    obj.AddSubRecord(c);
        //    obj.AddSubRecord(f);
        //    obj.AddSubRecord(l);
        //    obj.AddSubRecord(e);

        //    return obj;
        //}

        /**
         * Generates the escher shape records for this shape.
         */
        private EscherContainerRecord CreateSpContainer(HSSFSimpleShape shape, int shapeId)
        {
            EscherContainerRecord spContainer = new EscherContainerRecord();
            EscherSpRecord sp = new EscherSpRecord();
            EscherOptRecord opt = new EscherOptRecord();
            EscherClientDataRecord clientData = new EscherClientDataRecord();

            spContainer.RecordId=(EscherContainerRecord.SP_CONTAINER);
            spContainer.Options=((short)0x000F);
            sp.RecordId=(EscherSpRecord.RECORD_ID);
            sp.Options=((short)((EscherAggregate.ST_HOSTCONTROL << 4) | 0x2));

            sp.ShapeId=(shapeId);
            sp.Flags=(EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE);
            opt.RecordId=(EscherOptRecord.RECORD_ID);
            opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.PROTECTION__LOCKAGAINSTGROUPING, 17039620));
            opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 0x00080008));
            opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x00080000));
            opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.GROUPSHAPE__PRINT, 0x00020000));

            HSSFClientAnchor userAnchor = (HSSFClientAnchor)shape.Anchor;
            userAnchor.AnchorType = (AnchorType)1;
            EscherRecord anchor = CreateAnchor(userAnchor);
            clientData.RecordId=(EscherClientDataRecord.RECORD_ID);
            clientData.Options=((short)0x0000);

            spContainer.AddChildRecord(sp);
            spContainer.AddChildRecord(opt);
            spContainer.AddChildRecord(anchor);
            spContainer.AddChildRecord(clientData);

            return spContainer;
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates the lowerlevel escher records for this shape.
        /// </summary>
        /// <param name="hssfShape">The HSSF shape.</param>
        /// <param name="shapeId">The shape id.</param>
        /// <returns></returns>
        private EscherContainerRecord CreateSpContainer(HSSFSimpleShape hssfShape, int shapeId)
        {
            HSSFShape shape = hssfShape;

            EscherContainerRecord spContainer = new EscherContainerRecord();
            EscherSpRecord sp = new EscherSpRecord();
            EscherOptRecord opt = new EscherOptRecord();
            EscherClientDataRecord clientData = new EscherClientDataRecord();

            spContainer.RecordId=EscherContainerRecord.SP_CONTAINER;
            spContainer.Options=(short)0x000F;
            sp.RecordId=EscherSpRecord.RECORD_ID;
            short shapeType = objTypeToShapeType(hssfShape.ShapeType);
            sp.Options=(short)((shapeType << 4) | 0x2);
            sp.ShapeId=shapeId;
            sp.Flags=EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE;
            opt.RecordId=EscherOptRecord.RECORD_ID;
            AddStandardOptions(shape, opt);
            EscherRecord anchor = CreateAnchor(shape.Anchor);
            clientData.RecordId=EscherClientDataRecord.RECORD_ID;
            clientData.Options=(short)0x0000;

            spContainer.AddChildRecord(sp);
            spContainer.AddChildRecord(opt);
            spContainer.AddChildRecord(anchor);
            spContainer.AddChildRecord(clientData);

            return spContainer;
        }
Exemplo n.º 4
0
 /// <summary>
 /// Creates a simple shape.  This includes such shapes as lines, rectangles,
 /// and ovals.
 /// </summary>
 /// <param name="anchor">the client anchor describes how this Group is attached
 /// to the sheet.</param>
 /// <returns>the newly created shape.</returns>
 public HSSFSimpleShape CreateSimpleShape(HSSFClientAnchor anchor)
 {
     HSSFSimpleShape shape = new HSSFSimpleShape(null, anchor);
     shape.Anchor = anchor;
     shapes.Add(shape);
     return shape;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Create a new simple shape Under this Group.
 /// </summary>
 /// <param name="anchor">the position of the shape.</param>
 /// <returns>the shape</returns>
 public HSSFSimpleShape CreateShape(HSSFChildAnchor anchor)
 {
     HSSFSimpleShape shape = new HSSFSimpleShape(this, anchor);
     shape.Anchor = anchor;
     shapes.Add(shape);
     return shape;
 }
Exemplo n.º 6
0
        /// <summary>
        /// Creates a simple shape.  This includes such shapes as lines, rectangles,
        /// and ovals.
        /// </summary>
        /// <param name="anchor">the client anchor describes how this Group is attached
        /// to the sheet.</param>
        /// <returns>the newly created shape.</returns>
        public HSSFSimpleShape CreateSimpleShape(HSSFClientAnchor anchor)
        {
            HSSFSimpleShape shape = new HSSFSimpleShape(null, anchor);

            shape.Anchor = anchor;
            AddShape(shape);
            return(shape);
        }
Exemplo n.º 7
0
        public void DrawLine(int x1, int y1, int x2, int y2, int width)
        {
            HSSFSimpleShape shape = escherGroup.CreateShape(new HSSFChildAnchor(x1, y1, x2, y2));

            shape.ShapeType = (HSSFSimpleShape.OBJECT_TYPE_LINE);
            shape.LineWidth = (width);
            shape.SetLineStyleColor(foreground.R, foreground.G, foreground.B);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Create a new simple shape Under this Group.
        /// </summary>
        /// <param name="anchor">the position of the shape.</param>
        /// <returns>the shape</returns>
        public HSSFSimpleShape CreateShape(HSSFChildAnchor anchor)
        {
            HSSFSimpleShape shape = new HSSFSimpleShape(this, anchor);

            shape.Anchor = anchor;
            shapes.Add(shape);
            return(shape);
        }
Exemplo n.º 9
0
        /**
         * YK: used to create autofilters
         *
         * @see org.apache.poi.hssf.usermodel.HSSFSheet#setAutoFilter(int, int, int, int)
         */
        public HSSFSimpleShape CreateComboBox(HSSFAnchor anchor)
        {
            HSSFSimpleShape shape = new HSSFSimpleShape(null, anchor);

            shape.ShapeType = HSSFSimpleShape.OBJECT_TYPE_COMBO_BOX;
            shape.Anchor    = anchor;
            AddShape(shape);
            return(shape);
        }
Exemplo n.º 10
0
        public void FillOval(int x, int y, int width, int height)
        {
            HSSFSimpleShape shape = escherGroup.CreateShape(new HSSFChildAnchor(x, y, x + width, y + height));

            shape.ShapeType = (HSSFSimpleShape.OBJECT_TYPE_OVAL);
            shape.LineStyle = (HSSFShape.LINESTYLE_NONE);
            shape.SetFillColor(foreground.R, foreground.G, foreground.B);
            shape.SetLineStyleColor(foreground.R, foreground.G, foreground.B);
        }
Exemplo n.º 11
0
        public void DrawOval(int x, int y, int width, int height)
        {
            HSSFSimpleShape shape = escherGroup.CreateShape(new HSSFChildAnchor(x, y, x + width, y + height));

            shape.ShapeType = (HSSFSimpleShape.OBJECT_TYPE_OVAL);
            shape.LineWidth = 0;
            shape.SetLineStyleColor(foreground.R, foreground.G, foreground.B);
            shape.IsNoFill = (true);
        }
Exemplo n.º 12
0
        public void FillRect(int x, int y, int width, int height)
        {
            HSSFSimpleShape shape = escherGroup.CreateShape(new HSSFChildAnchor(x, y, x + width, y + height));

            shape.ShapeType = (HSSFSimpleShape.OBJECT_TYPE_RECTANGLE);
            shape.LineStyle = LineStyle.None;
            shape.SetFillColor(foreground.R, foreground.G, foreground.B);
            shape.SetLineStyleColor(foreground.R, foreground.G, foreground.B);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Creates a simple shape.  This includes such shapes as lines, rectangles,
        /// and ovals.
        /// </summary>
        /// <param name="anchor">the client anchor describes how this Group is attached
        /// to the sheet.</param>
        /// <returns>the newly created shape.</returns>
        public HSSFSimpleShape CreateSimpleShape(HSSFClientAnchor anchor)
        {
            HSSFSimpleShape shape = new HSSFSimpleShape(null, anchor);

            AddShape(shape);
            //open existing file
            OnCreate(shape);
            return(shape);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Create a new simple shape Under this Group.
        /// </summary>
        /// <param name="anchor">the position of the shape.</param>
        /// <returns>the shape</returns>
        public HSSFSimpleShape CreateShape(HSSFChildAnchor anchor)
        {
            HSSFSimpleShape shape = new HSSFSimpleShape(this, anchor);

            shape.Parent = this;
            shape.Anchor = anchor;
            shapes.Add(shape);
            OnCreate(shape);
            EscherSpRecord sp = (EscherSpRecord)shape.GetEscherContainer().GetChildById(EscherSpRecord.RECORD_ID);

            if (shape.Anchor.IsHorizontallyFlipped)
            {
                sp.Flags = (sp.Flags | EscherSpRecord.FLAG_FLIPHORIZ);
            }
            if (shape.Anchor.IsVerticallyFlipped)
            {
                sp.Flags = (sp.Flags | EscherSpRecord.FLAG_FLIPVERT);
            }
            return(shape);
        }
Exemplo n.º 15
0
        /**
         * Creates the low level OBJ record for this shape.
         */
        private ObjRecord CreateObjRecord(HSSFSimpleShape shape, int shapeId)
        {
            ObjRecord obj = new ObjRecord();
            CommonObjectDataSubRecord c = new CommonObjectDataSubRecord();
            c.ObjectType= CommonObjectType.COMBO_BOX;
            c.ObjectId= (short)shapeId;
            c.IsLocked=(true);
            c.IsPrintable=false;
            c.IsAutoFill=true;
            c.IsAutoline=false;

            LbsDataSubRecord l = LbsDataSubRecord.CreateAutoFilterInstance();

            EndSubRecord e = new EndSubRecord();

            obj.AddSubRecord(c);
            obj.AddSubRecord(l);
            obj.AddSubRecord(e);

            return obj;
        }
Exemplo n.º 16
0
        /// <summary>
        /// Creates the lowerlevel escher records for this shape.
        /// </summary>
        /// <param name="hssfShape">The HSSF shape.</param>
        /// <param name="shapeId">The shape id.</param>
        /// <returns></returns>
        private EscherContainerRecord CreateSpContainer(HSSFSimpleShape hssfShape, int shapeId)
        {
            HSSFPicture shape = (HSSFPicture)hssfShape;

            EscherContainerRecord spContainer = new EscherContainerRecord();
            EscherSpRecord sp = new EscherSpRecord();
            EscherOptRecord opt = new EscherOptRecord();
            EscherRecord anchor;
            EscherClientDataRecord clientData = new EscherClientDataRecord();

            spContainer.RecordId=EscherContainerRecord.SP_CONTAINER;
            spContainer.Options=(short)0x000F;
            sp.RecordId=EscherSpRecord.RECORD_ID;
            sp.Options=(short)((EscherAggregate.ST_PICTUREFRAME << 4) | 0x2);

            sp.ShapeId=shapeId;
            sp.Flags=EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE;
            opt.RecordId=EscherOptRecord.RECORD_ID;
            //        opt.AddEscherProperty( new EscherBoolProperty( EscherProperties.PROTECTION__LOCKAGAINSTGROUPING, 0x00800080 ) ;
            opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.BLIP__BLIPTODISPLAY, false, true, shape.PictureIndex));
            //        opt.AddEscherProperty( new EscherComplexProperty( EscherProperties.BLIP__BLIPFILENAME, true, new byte[] { (byte)0x74, (byte)0x00, (byte)0x65, (byte)0x00, (byte)0x73, (byte)0x00, (byte)0x74, (byte)0x00, (byte)0x00, (byte)0x00 } ) ;
            //        opt.AddEscherProperty( new EscherSimpleProperty( EscherProperties.Fill__FillTYPE, 0x00000003 ) ;
            AddStandardOptions(shape, opt);
            HSSFAnchor userAnchor = shape.Anchor;
            if (userAnchor.IsHorizontallyFlipped)
                sp.Flags=sp.Flags | EscherSpRecord.FLAG_FLIPHORIZ;
            if (userAnchor.IsVerticallyFlipped)
                sp.Flags=sp.Flags | EscherSpRecord.FLAG_FLIPVERT;
            anchor = CreateAnchor(userAnchor);
            clientData.RecordId=EscherClientDataRecord.RECORD_ID;
            clientData.Options=(short)0x0000;

            spContainer.AddChildRecord(sp);
            spContainer.AddChildRecord(opt);
            spContainer.AddChildRecord(anchor);
            spContainer.AddChildRecord(clientData);

            return spContainer;
        }
Exemplo n.º 17
0
        /// <summary>
        /// Creates the lowerlevel escher records for this shape.
        /// </summary>
        /// <param name="hssfShape">The HSSF shape.</param>
        /// <param name="shapeId">The shape id.</param>
        /// <returns></returns>
        private EscherContainerRecord CreateSpContainer(HSSFSimpleShape hssfShape, int shapeId)
        {
            HSSFShape shape = hssfShape;

            EscherContainerRecord spContainer = new EscherContainerRecord();
            EscherSpRecord sp = new EscherSpRecord();
            EscherOptRecord opt = new EscherOptRecord();
            EscherRecord anchor = new EscherClientAnchorRecord();
            EscherClientDataRecord clientData = new EscherClientDataRecord();

            spContainer.RecordId=EscherContainerRecord.SP_CONTAINER;
            spContainer.Options=(short)0x000F;
            sp.RecordId=EscherSpRecord.RECORD_ID;
            sp.Options=(short)((EscherAggregate.ST_LINE << 4) | 0x2);

            sp.ShapeId=shapeId;
            sp.Flags=EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE;
            opt.RecordId=EscherOptRecord.RECORD_ID;
            opt.AddEscherProperty(new EscherShapePathProperty(EscherProperties.GEOMETRY__SHAPEPATH, EscherShapePathProperty.COMPLEX));
            opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 1048592));
            AddStandardOptions(shape, opt);
            HSSFAnchor userAnchor = shape.Anchor;
            if (userAnchor.IsHorizontallyFlipped)
                sp.Flags=sp.Flags | EscherSpRecord.FLAG_FLIPHORIZ;
            if (userAnchor.IsVerticallyFlipped)
                sp.Flags=sp.Flags | EscherSpRecord.FLAG_FLIPVERT;
            anchor = CreateAnchor(userAnchor);
            clientData.RecordId=EscherClientDataRecord.RECORD_ID;
            clientData.Options=((short)0x0000);

            spContainer.AddChildRecord(sp);
            spContainer.AddChildRecord(opt);
            spContainer.AddChildRecord(anchor);
            spContainer.AddChildRecord(clientData);

            return spContainer;
        }
Exemplo n.º 18
0
 public static TextObjectRecord GetTextObjRecord(HSSFSimpleShape shape)
 {
     return shape.GetTextObjectRecord();
 }
Exemplo n.º 19
0
 /**
  * YK: used to create autofilters
  *
  * @see org.apache.poi.hssf.usermodel.HSSFSheet#setAutoFilter(int, int, int, int)
  */
 public HSSFSimpleShape CreateComboBox(HSSFAnchor anchor)
 {
     HSSFSimpleShape shape = new HSSFSimpleShape(null, anchor);
     shape.ShapeType = HSSFSimpleShape.OBJECT_TYPE_COMBO_BOX;
     shape.Anchor = anchor;
     AddShape(shape);
     return shape;
 }
Exemplo n.º 20
0
 /**
  * Creates the low evel records for a combobox.
  *
  * @param hssfShape The highlevel shape.
  * @param shapeId   The shape id to use for this shape.
  */
 public ComboboxShape(HSSFSimpleShape hssfShape, int shapeId)
 {
     spContainer = CreateSpContainer(hssfShape, shapeId);
     //objRecord = CreateObjRecord(hssfShape, shapeId);
 }
Exemplo n.º 21
0
 /// <summary>
 /// Creates the low evel records for an oval.
 /// </summary>
 /// <param name="hssfShape">The highlevel shape.</param>
 /// <param name="shapeId">The shape id to use for this shape.</param>
 public SimpleFilledShape(HSSFSimpleShape hssfShape, int shapeId)
 {
     spContainer = CreateSpContainer(hssfShape, shapeId);
     objRecord = CreateObjRecord(hssfShape, shapeId);
 }
Exemplo n.º 22
0
 /// <summary>
 /// Create a new simple shape Under this Group.
 /// </summary>
 /// <param name="anchor">the position of the shape.</param>
 /// <returns>the shape</returns>
 public HSSFSimpleShape CreateShape(HSSFChildAnchor anchor)
 {
     HSSFSimpleShape shape = new HSSFSimpleShape(this, anchor);
     shape.Parent = this;
     shape.Anchor = anchor;
     shapes.Add(shape);
     OnCreate(shape);
     EscherSpRecord sp = (EscherSpRecord)shape.GetEscherContainer().GetChildById(EscherSpRecord.RECORD_ID);
     if (shape.Anchor.IsHorizontallyFlipped)
     {
         sp.Flags = (sp.Flags | EscherSpRecord.FLAG_FLIPHORIZ);
     }
     if (shape.Anchor.IsVerticallyFlipped)
     {
         sp.Flags = (sp.Flags | EscherSpRecord.FLAG_FLIPVERT);
     }
     return shape;
 }
Exemplo n.º 23
0
        /// <summary>
        /// Creates a simple shape.  This includes such shapes as lines, rectangles,
        /// and ovals.
        /// </summary>
        /// <param name="anchor">the client anchor describes how this Group is attached
        /// to the sheet.</param>
        /// <returns>the newly created shape.</returns>
        public HSSFSimpleShape CreateSimpleShape(HSSFClientAnchor anchor)
        {
            HSSFSimpleShape shape = new HSSFSimpleShape(null, anchor);

            AddShape(shape);
            //open existing file
            OnCreate(shape);
            return shape;
        }
Exemplo n.º 24
0
        /**
         * build shape tree from escher container
         * @param container root escher container from which escher records must be taken
         * @param agg - EscherAggregate
         * @param out - shape container to which shapes must be added
         * @param root - node to create HSSFObjectData shapes
         */
        public static void CreateShapeTree(EscherContainerRecord container, EscherAggregate agg,
                                           HSSFShapeContainer out1, DirectoryNode root)
        {
            if (container.RecordId == EscherContainerRecord.SPGR_CONTAINER)
            {
                ObjRecord obj = null;
                EscherClientDataRecord clientData = (EscherClientDataRecord)((EscherContainerRecord)container.GetChild(0)).GetChildById(EscherClientDataRecord.RECORD_ID);
                if (null != clientData)
                {
                    obj = (ObjRecord)agg.GetShapeToObjMapping()[clientData];
                }
                HSSFShapeGroup group = new HSSFShapeGroup(container, obj);
                IList <EscherContainerRecord> children = container.ChildContainers;
                // skip the first child record, it is group descriptor
                for (int i = 0; i < children.Count; i++)
                {
                    EscherContainerRecord spContainer = children[(i)];
                    if (i != 0)
                    {
                        CreateShapeTree(spContainer, agg, group, root);
                    }
                }
                out1.AddShape(group);
            }
            else if (container.RecordId == EscherContainerRecord.SP_CONTAINER)
            {
                Dictionary <EscherRecord, Record.Record> shapeToObj = agg.GetShapeToObjMapping();
                ObjRecord        objRecord = null;
                TextObjectRecord txtRecord = null;

                foreach (EscherRecord record in container.ChildRecords)
                {
                    switch (record.RecordId)
                    {
                    case EscherClientDataRecord.RECORD_ID:
                        objRecord = (ObjRecord)shapeToObj[(record)];
                        break;

                    case EscherTextboxRecord.RECORD_ID:
                        txtRecord = (TextObjectRecord)shapeToObj[(record)];
                        break;

                    default:
                        break;
                    }
                }
                if (IsEmbeddedObject(objRecord))
                {
                    HSSFObjectData objectData = new HSSFObjectData(container, objRecord, root);
                    out1.AddShape(objectData);
                    return;
                }
                CommonObjectDataSubRecord cmo = (CommonObjectDataSubRecord)objRecord.SubRecords[0];
                HSSFShape shape;
                switch (cmo.ObjectType)
                {
                case CommonObjectType.Picture:
                    shape = new HSSFPicture(container, objRecord);
                    break;

                case CommonObjectType.Rectangle:
                    shape = new HSSFSimpleShape(container, objRecord, txtRecord);
                    break;

                case CommonObjectType.Line:
                    shape = new HSSFSimpleShape(container, objRecord);
                    break;

                case CommonObjectType.ComboBox:
                    shape = new HSSFCombobox(container, objRecord);
                    break;

                case CommonObjectType.MicrosoftOfficeDrawing:
                    EscherOptRecord optRecord = (EscherOptRecord)container.GetChildById(EscherOptRecord.RECORD_ID);
                    if (optRecord == null)
                    {
                        shape = new HSSFSimpleShape(container, objRecord, txtRecord);
                    }
                    else
                    {
                        EscherProperty property = optRecord.Lookup(EscherProperties.GEOMETRY__VERTICES);
                        if (null != property)
                        {
                            shape = new HSSFPolygon(container, objRecord, txtRecord);
                        }
                        else
                        {
                            shape = new HSSFSimpleShape(container, objRecord, txtRecord);
                        }
                    }
                    break;

                case CommonObjectType.Text:
                    shape = new HSSFTextbox(container, objRecord, txtRecord);
                    break;

                case CommonObjectType.Comment:
                    shape = new HSSFComment(container, objRecord, txtRecord, agg.GetNoteRecordByObj(objRecord));
                    break;

                default:
                    shape = new HSSFSimpleShape(container, objRecord, txtRecord);
                    break;
                }
                out1.AddShape(shape);
            }
        }
Exemplo n.º 25
0
        /**
         * build shape tree from escher container
         * @param container root escher container from which escher records must be taken
         * @param agg - EscherAggregate
         * @param out - shape container to which shapes must be added
         * @param root - node to create HSSFObjectData shapes
         */
        public static void CreateShapeTree(EscherContainerRecord container, EscherAggregate agg,
            HSSFShapeContainer out1, DirectoryNode root)
        {
            if (container.RecordId == EscherContainerRecord.SPGR_CONTAINER)
            {
                ObjRecord obj = null;
                EscherClientDataRecord clientData = (EscherClientDataRecord)((EscherContainerRecord)container.GetChild(0)).GetChildById(EscherClientDataRecord.RECORD_ID);
                if (null != clientData)
                {
                    obj = (ObjRecord)agg.GetShapeToObjMapping()[clientData];
                }
                HSSFShapeGroup group = new HSSFShapeGroup(container, obj);
                IList<EscherContainerRecord> children = container.ChildContainers;
                // skip the first child record, it is group descriptor
                for (int i = 0; i < children.Count; i++)
                {
                    EscherContainerRecord spContainer = children[(i)];
                    if (i != 0)
                    {
                        CreateShapeTree(spContainer, agg, group, root);
                    }
                }
                out1.AddShape(group);
            }
            else if (container.RecordId == EscherContainerRecord.SP_CONTAINER)
            {
                Dictionary<EscherRecord, Record.Record> shapeToObj = agg.GetShapeToObjMapping();
                ObjRecord objRecord = null;
                TextObjectRecord txtRecord = null;

                foreach (EscherRecord record in container.ChildRecords)
                {
                    switch (record.RecordId)
                    {
                        case EscherClientDataRecord.RECORD_ID:
                            objRecord = (ObjRecord)shapeToObj[(record)];
                            break;
                        case EscherTextboxRecord.RECORD_ID:
                            txtRecord = (TextObjectRecord)shapeToObj[(record)];
                            break;
                    }
                }
                if (IsEmbeddedObject(objRecord))
                {
                    HSSFObjectData objectData = new HSSFObjectData(container, objRecord, root);
                    out1.AddShape(objectData);
                    return;
                }
                CommonObjectDataSubRecord cmo = (CommonObjectDataSubRecord)objRecord.SubRecords[0];
                HSSFShape shape;
                switch (cmo.ObjectType)
                {
                    case CommonObjectType.Picture:
                        shape = new HSSFPicture(container, objRecord);
                        break;
                    case CommonObjectType.Rectangle:
                        shape = new HSSFSimpleShape(container, objRecord, txtRecord);
                        break;
                    case CommonObjectType.Line:
                        shape = new HSSFSimpleShape(container, objRecord);
                        break;
                    case CommonObjectType.ComboBox:
                        shape = new HSSFCombobox(container, objRecord);
                        break;
                    case CommonObjectType.MicrosoftOfficeDrawing:
                        EscherOptRecord optRecord = (EscherOptRecord)container.GetChildById(EscherOptRecord.RECORD_ID);
                        EscherProperty property = optRecord.Lookup(EscherProperties.GEOMETRY__VERTICES);
                        if (null != property)
                        {
                            shape = new HSSFPolygon(container, objRecord, txtRecord);
                        }
                        else
                        {
                            shape = new HSSFSimpleShape(container, objRecord, txtRecord);
                        }
                        break;
                    case CommonObjectType.Text:
                        shape = new HSSFTextbox(container, objRecord, txtRecord);
                        break;
                    case CommonObjectType.Comment:
                        shape = new HSSFComment(container, objRecord, txtRecord, agg.GetNoteRecordByObj(objRecord));
                        break;
                    default:
                        shape = new HSSFSimpleShape(container, objRecord, txtRecord);
                        break;
                }
                out1.AddShape(shape);
            }
        }