Example #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);
        }
Example #2
0
        /// <summary>
        /// Creates the low level OBJ record for this shape.
        /// </summary>
        /// <param name="hssfShape">The HSSFShape.</param>
        /// <param name="shapeId">The shape id.</param>
        /// <returns></returns>
        private ObjRecord CreateObjRecord(HSSFShape hssfShape, int shapeId)
        {
            HSSFShape shape = hssfShape;

            ObjRecord obj = new ObjRecord();
            CommonObjectDataSubRecord c = new CommonObjectDataSubRecord();

            c.ObjectType = (CommonObjectType)((HSSFSimpleShape)shape).ShapeType;
            //        c.ObjectId((short) ( 1 ));
            c.ObjectId    = GetCmoObjectId(shapeId);
            c.IsLocked    = true;
            c.IsPrintable = true;
            c.IsAutoFill  = true;
            c.IsAutoline  = true;
            //        c.Reserved2( 0x012C0A84 );
            c.Reserved2 = (0x0);
            //        UnknownRecord sub1 = new UnknownRecord( (short)0x7, (short)0x2, new byte[] { 0x09, 0x00 } );
            //        UnknownRecord sub2 = new UnknownRecord( (short)0x8, (short)0x2, new byte[] { 0x01, 0x00 } );
            EndSubRecord e = new EndSubRecord();

            obj.AddSubRecord(c);
            //        obj.AddSubRecord( sub1 );
            //        obj.AddSubRecord( sub2 );
            obj.AddSubRecord(e);

            return(obj);
        }
Example #3
0
        public void TestConstruct()
        {
            ObjRecord record = new ObjRecord();
            CommonObjectDataSubRecord ftCmo = new CommonObjectDataSubRecord();

            ftCmo.ObjectType  = (CommonObjectType.Comment);
            ftCmo.ObjectId    = ((short)1024);
            ftCmo.IsLocked    = (true);
            ftCmo.IsPrintable = (true);
            ftCmo.IsAutoFill  = (true);
            ftCmo.IsAutoline  = (true);
            record.AddSubRecord(ftCmo);
            EndSubRecord ftEnd = new EndSubRecord();

            record.AddSubRecord(ftEnd);

            //Serialize and Read again
            byte[] recordBytes = record.Serialize();
            //cut off the record header
            byte[] bytes = new byte[recordBytes.Length - 4];
            System.Array.Copy(recordBytes, 4, bytes, 0, bytes.Length);

            record = new ObjRecord(TestcaseRecordInputStream.Create(ObjRecord.sid, bytes));
            IList subrecords = record.SubRecords;

            Assert.AreEqual(2, subrecords.Count);
            Assert.IsTrue(subrecords[0] is CommonObjectDataSubRecord);
            Assert.IsTrue(subrecords[1] is EndSubRecord);
        }
Example #4
0
        public void TestStore()
        {
            EndSubRecord record = new EndSubRecord();

            byte[] recordBytes = record.Serialize();
            Assert.AreEqual(recordBytes.Length - 4, data.Length);
            for (int i = 0; i < data.Length; i++)
            {
                Assert.AreEqual(data[i], recordBytes[i + 4], "At offset " + i);
            }
        }
Example #5
0
        protected override ObjRecord CreateObjRecord()
        {
            ObjRecord obj = new ObjRecord();
            CommonObjectDataSubRecord c = new CommonObjectDataSubRecord();

            c.IsLocked    = true;
            c.IsPrintable = true;
            c.IsAutoFill  = true;
            c.IsAutoline  = true;
            EndSubRecord e = new EndSubRecord();

            obj.AddSubRecord(c);
            obj.AddSubRecord(e);
            return(obj);
        }
Example #6
0
        /**
         * Creates the low level OBJ record for this shape.
         */
        protected override ObjRecord CreateObjRecord()
        {
            ObjRecord obj = new ObjRecord();
            CommonObjectDataSubRecord c = new CommonObjectDataSubRecord();

            c.ObjectType  = CommonObjectType.MICROSOFT_OFFICE_DRAWING;
            c.IsLocked    = (true);
            c.IsPrintable = (true);
            c.IsAutoFill  = (true);
            c.IsAutoline  = (true);
            EndSubRecord e = new EndSubRecord();

            obj.AddSubRecord(c);
            obj.AddSubRecord(e);
            return(obj);
        }
Example #7
0
        /**
         * Creates the low level OBJ record for this shape.
         */

        protected override ObjRecord CreateObjRecord()
        {
            ObjRecord obj = new ObjRecord();
            CommonObjectDataSubRecord c = new CommonObjectDataSubRecord();

            c.ObjectType  = CommonObjectType.MicrosoftOfficeDrawing;
            c.IsLocked    = (true);
            c.IsPrintable = (true);
            c.IsAutoFill  = (true);
            c.IsAutoline  = (true);
            EndSubRecord e = new EndSubRecord();

            obj.AddSubRecord(c);
            obj.AddSubRecord(e);
            return(obj);
        }
Example #8
0
        protected override ObjRecord CreateObjRecord()
        {
            ObjRecord obj = new ObjRecord();
            CommonObjectDataSubRecord cmo = new CommonObjectDataSubRecord();

            cmo.ObjectType  = (CommonObjectType.Group);
            cmo.IsLocked    = (true);
            cmo.IsPrintable = (true);
            cmo.IsAutoFill  = (true);
            cmo.IsAutoline  = (true);
            GroupMarkerSubRecord gmo = new GroupMarkerSubRecord();
            EndSubRecord         end = new EndSubRecord();

            obj.AddSubRecord(cmo);
            obj.AddSubRecord(gmo);
            obj.AddSubRecord(end);
            return(obj);
        }
Example #9
0
        /// <summary>
        /// Creates the low level OBJ record for this shape.
        /// </summary>
        /// <param name="hssfShape">The HSSF shape.</param>
        /// <param name="shapeId">The shape id.</param>
        /// <returns></returns>
        private ObjRecord CreateObjRecord(HSSFShape hssfShape, int shapeId)
        {
            HSSFShape shape = hssfShape;

            ObjRecord obj = new ObjRecord();
            CommonObjectDataSubRecord c = new CommonObjectDataSubRecord();
            c.ObjectType = (CommonObjectType)((HSSFSimpleShape)shape).ShapeType;
            c.ObjectId = GetCmoObjectId(shapeId);
            c.IsLocked = true;
            c.IsPrintable = true;
            c.IsAutoFill = true;
            c.IsAutoline = true;
            EndSubRecord e = new EndSubRecord();

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

            return obj;
        }
Example #10
0
        /// <summary>
        /// Creates the lowerlevel OBJ records for this shape.
        /// </summary>
        /// <param name="hssfShape">The HSSF shape.</param>
        /// <param name="shapeId">The shape id.</param>
        /// <returns></returns>
        private ObjRecord CreateObjRecord(HSSFTextbox hssfShape, int shapeId)
        {
            HSSFShape shape = hssfShape;

            ObjRecord obj = new ObjRecord();
            CommonObjectDataSubRecord c = new CommonObjectDataSubRecord();
            c.ObjectType = (CommonObjectType)((HSSFSimpleShape)shape).ShapeType;
            c.ObjectId = GetCmoObjectId(shapeId);
            c.IsLocked = true;
            c.IsPrintable = true;
            c.IsAutoFill = true;
            c.IsAutoline = true;
            EndSubRecord e = new EndSubRecord();

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

            return obj;
        }
Example #11
0
        protected override ObjRecord CreateObjRecord()
        {
            ObjRecord obj = new ObjRecord();
            CommonObjectDataSubRecord c = new CommonObjectDataSubRecord();

            c.ObjectType  = (CommonObjectType)OBJECT_TYPE_COMMENT;
            c.IsLocked    = (true);
            c.IsPrintable = (true);
            c.IsAutoFill  = (false);
            c.IsAutoline  = (true);

            NoteStructureSubRecord u = new NoteStructureSubRecord();
            EndSubRecord           e = new EndSubRecord();

            obj.AddSubRecord(c);
            obj.AddSubRecord(u);
            obj.AddSubRecord(e);
            return(obj);
        }
Example #12
0
        public static Record CreateSubRecord(RecordInputStream in1)
        {
            Record r = null;

            /* This must surely be an earlier hack?? Delete when confident
            short adjustedSize = size;
            if ( size < 0 )
            {
                adjustedSize = 0;
            }
            else if ( offset + size > data.Length )
            {
                adjustedSize = (short) ( data.Length - offset );
                if ( adjustedSize > 4 )
                {
                    adjustedSize -= 4;
                }
            }
    */
            switch (in1.Sid)
            {
                case CommonObjectDataSubRecord.sid:
                    r = new CommonObjectDataSubRecord(in1);
                    break;
                case EmbeddedObjectRefSubRecord.sid:
                    r = new EmbeddedObjectRefSubRecord(in1);
                    break;
                case GroupMarkerSubRecord.sid:
                    r = new GroupMarkerSubRecord(in1);
                    break;
                case EndSubRecord.sid:
                    r = new EndSubRecord(in1);
                    break;
                case NoteStructureSubRecord.sid:
                    r = new NoteStructureSubRecord(in1);
                    break;
                default:
                    r = new UnknownRecord(in1);
                    break;
            }
            return r;
        }
Example #13
0
        /// <summary>
        /// Creates the lowerlevel OBJ records for this shape.
        /// </summary>
        /// <param name="hssfShape">The HSSF shape.</param>
        /// <param name="shapeId">The shape id.</param>
        /// <returns></returns>
        private ObjRecord CreateObjRecord(HSSFShape hssfShape, int shapeId)
        {
            HSSFShape shape = hssfShape;

            ObjRecord obj = new ObjRecord();
            CommonObjectDataSubRecord c = new CommonObjectDataSubRecord();

            c.ObjectType  = CommonObjectType.MICROSOFT_OFFICE_DRAWING;
            c.ObjectId    = ((short)(shapeId));
            c.IsLocked    = (true);
            c.IsPrintable = (true);
            c.IsAutoFill  = (true);
            c.IsAutoline  = (true);
            EndSubRecord e = new EndSubRecord();

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

            return(obj);
        }
Example #14
0
        /// <summary>
        /// Creates the lowerlevel OBJ records for this shape.
        /// </summary>
        /// <param name="hssfShape">The HSSF shape.</param>
        /// <param name="shapeId">The shape id.</param>
        /// <returns></returns>
        private ObjRecord CreateObjRecord(HSSFTextbox hssfShape, int shapeId)
        {
            HSSFShape shape = hssfShape;

            ObjRecord obj = new ObjRecord();
            CommonObjectDataSubRecord c = new CommonObjectDataSubRecord();

            c.ObjectType  = (CommonObjectType)((HSSFSimpleShape)shape).ShapeType;
            c.ObjectId    = ((short)(shapeId));
            c.IsLocked    = (true);
            c.IsPrintable = (true);
            c.IsAutoFill  = (true);
            c.IsAutoline  = (true);
            EndSubRecord e = new EndSubRecord();

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

            return(obj);
        }
Example #15
0
        /// <summary>
        /// Creates the lowerlevel OBJ records for this shape.
        /// </summary>
        /// <param name="hssfShape">The HSSF shape.</param>
        /// <param name="shapeId">The shape id.</param>
        /// <returns></returns>
        private ObjRecord CreateObjRecord(HSSFShape hssfShape, int shapeId)
        {
            HSSFShape shape = hssfShape;

            ObjRecord obj = new ObjRecord();
            CommonObjectDataSubRecord c = new CommonObjectDataSubRecord();

            c.ObjectType  = (CommonObjectType)OBJECT_TYPE_MICROSOFT_OFFICE_DRAWING;
            c.ObjectId    = GetCmoObjectId(shapeId);
            c.IsLocked    = true;
            c.IsPrintable = true;
            c.IsAutoFill  = true;
            c.IsAutoline  = true;
            EndSubRecord e = new EndSubRecord();

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

            return(obj);
        }
Example #16
0
        protected override ObjRecord CreateObjRecord()
        {
            ObjRecord obj = new ObjRecord();
            CommonObjectDataSubRecord c = new CommonObjectDataSubRecord();

            c.ObjectType  = CommonObjectType.COMBO_BOX;
            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);
        }
Example #17
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;
        }
Example #18
0
        /// <summary>
        /// Creates the low level OBJ record for this shape.
        /// </summary>
        /// <param name="hssfShape">The HSSFShape.</param>
        /// <param name="shapeId">The shape id.</param>
        /// <returns></returns>
        private ObjRecord CreateObjRecord(HSSFShape hssfShape, int shapeId)
        {
            HSSFShape shape = hssfShape;

            ObjRecord obj = new ObjRecord();
            CommonObjectDataSubRecord c = new CommonObjectDataSubRecord();
            c.ObjectType=(CommonObjectType)((HSSFSimpleShape)shape).ShapeType;
            //        c.ObjectId((short) ( 1 ));
            c.ObjectId = GetCmoObjectId(shapeId);
            c.IsLocked=true;
            c.IsPrintable=true;
            c.IsAutoFill=true;
            c.IsAutoline=true;
            //        c.Reserved2( 0x012C0A84 );
            c.Reserved2=(0x0);
            //        UnknownRecord sub1 = new UnknownRecord( (short)0x7, (short)0x2, new byte[] { 0x09, 0x00 } );
            //        UnknownRecord sub2 = new UnknownRecord( (short)0x8, (short)0x2, new byte[] { 0x01, 0x00 } );
            EndSubRecord e = new EndSubRecord();

            obj.AddSubRecord(c);
            //        obj.AddSubRecord( sub1 );
            //        obj.AddSubRecord( sub2 );
            obj.AddSubRecord(e);

            return obj;
        }
Example #19
0
        private void ConvertGroup(HSSFShapeGroup shape, EscherContainerRecord escherParent, Hashtable shapeToObj)
        {
            EscherContainerRecord spgrContainer = new EscherContainerRecord();
            EscherContainerRecord spContainer = new EscherContainerRecord();
            EscherSpgrRecord spgr = new EscherSpgrRecord();
            EscherSpRecord sp = new EscherSpRecord();
            EscherOptRecord opt = new EscherOptRecord();
            EscherRecord anchor;
            EscherClientDataRecord clientData = new EscherClientDataRecord();

            spgrContainer.RecordId = EscherContainerRecord.SPGR_CONTAINER;
            spgrContainer.Options = (short)0x000F;
            spContainer.RecordId = EscherContainerRecord.SP_CONTAINER;
            spContainer.Options = (short)0x000F;
            spgr.RecordId = EscherSpgrRecord.RECORD_ID;
            spgr.Options = (short)0x0001;
            spgr.RectX1 = shape.X1;
            spgr.RectY1 = shape.Y1;
            spgr.RectX2 = shape.X2;
            spgr.RectY2 = shape.Y2;
            sp.RecordId = EscherSpRecord.RECORD_ID;
            sp.Options = (short)0x0002;
            int shapeId = drawingManager.AllocateShapeId(drawingGroupId);
            sp.ShapeId = shapeId;
            if (shape.Anchor is HSSFClientAnchor)
                sp.Flags = EscherSpRecord.FLAG_GROUP | EscherSpRecord.FLAG_HAVEANCHOR;
            else
                sp.Flags = EscherSpRecord.FLAG_GROUP | EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_CHILD;
            opt.RecordId = EscherOptRecord.RECORD_ID;
            opt.Options = (short)0x0023;
            opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.PROTECTION__LOCKAGAINSTGROUPING, 0x00040004));
            opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.GROUPSHAPE__PRINT, 0x00080000));

            anchor = ConvertAnchor.CreateAnchor(shape.Anchor);
            //        clientAnchor.Col1( ( (HSSFClientAnchor) shape.Anchor ).Col1 );
            //        clientAnchor.Row1( (short) ( (HSSFClientAnchor) shape.Anchor ).Row1 );
            //        clientAnchor.Dx1( (short) shape.Anchor.Dx1 );
            //        clientAnchor.Dy1( (short) shape.Anchor.Dy1 );
            //        clientAnchor.Col2( ( (HSSFClientAnchor) shape.Anchor ).Col2 );
            //        clientAnchor.Row2( (short) ( (HSSFClientAnchor) shape.Anchor ).Row2 );
            //        clientAnchor.Dx2( (short) shape.Anchor.Dx2 );
            //        clientAnchor.Dy2( (short) shape.Anchor.Dy2 );
            clientData.RecordId = (EscherClientDataRecord.RECORD_ID);
            clientData.Options = ((short)0x0000);

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

            ObjRecord obj = new ObjRecord();
            CommonObjectDataSubRecord cmo = new CommonObjectDataSubRecord();
            cmo.ObjectType = CommonObjectType.GROUP;
            cmo.ObjectId = shapeId;
            cmo.IsLocked = true;
            cmo.IsPrintable = true;
            cmo.IsAutoFill = true;
            cmo.IsAutoline = true;
            GroupMarkerSubRecord gmo = new GroupMarkerSubRecord();
            EndSubRecord end = new EndSubRecord();
            obj.AddSubRecord(cmo);
            obj.AddSubRecord(gmo);
            obj.AddSubRecord(end);
            shapeToObj[clientData] = obj;

            escherParent.AddChildRecord(spgrContainer);

            ConvertShapes(shape, spgrContainer, shapeToObj);

        }
Example #20
0
        /// <summary>
        /// Creates the lowerlevel OBJ records for this shape.
        /// </summary>
        /// <param name="hssfShape">The HSSF shape.</param>
        /// <param name="shapeId">The shape id.</param>
        /// <returns></returns>
        private ObjRecord CreateObjRecord(HSSFShape hssfShape, int shapeId)
        {
            HSSFShape shape = hssfShape;

            ObjRecord obj = new ObjRecord();
            CommonObjectDataSubRecord c = new CommonObjectDataSubRecord();
            c.ObjectType = CommonObjectType.MICROSOFT_OFFICE_DRAWING;
            c.ObjectId = shapeId;
            c.IsLocked = true;
            c.IsPrintable = true;
            c.IsAutoFill = true;
            c.IsAutoline = true;
            EndSubRecord e = new EndSubRecord();

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

            return obj;
        }
Example #21
0
        public void TestLoad()
        {
            EndSubRecord record = new EndSubRecord(TestcaseRecordInputStream.Create((short)0x00, data), data.Length);

            Assert.AreEqual(0, record.DataSize);
        }