Ejemplo n.º 1
0
 protected override ObjRecord CreateObjRecord()
 {
     ObjRecord obj = new ObjRecord();
     CommonObjectDataSubRecord c = new CommonObjectDataSubRecord();
     c.ObjectType = CommonObjectType.TEXT;
     c.IsLocked = (true);
     c.IsPrintable = (true);
     c.IsAutoFill = (true);
     c.IsAutoline = (true);
     EndSubRecord e = new EndSubRecord();
     obj.AddSubRecord(c);
     obj.AddSubRecord(e);
     return obj;
 }
Ejemplo n.º 2
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;
        }
Ejemplo n.º 3
0
        public override Object Clone()
        {
            ObjRecord rec = new ObjRecord();

            for (int i = 0; i < subrecords.Count; i++)
            {
                SubRecord record = subrecords[i];
                rec.AddSubRecord((SubRecord)record.Clone());
            }

            return(rec);
        }
Ejemplo n.º 4
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;
        }
Ejemplo n.º 5
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;
        }
Ejemplo n.º 6
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=((short)((HSSFSimpleShape)shape).ShapeType);
            //        c.ObjectId((short) ( 1 ));
            c.ObjectId=((short)(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;
        }
Ejemplo n.º 7
0
        /**
         * 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
        }
Ejemplo n.º 8
0
        public override Object Clone()
        {
            ObjRecord rec = new ObjRecord();

            for (int i = 0; i < subrecords.Count; i++)
            {
                SubRecord record = subrecords[i];
                rec.AddSubRecord((SubRecord)record.Clone());
            }

            return rec;
        }
Ejemplo n.º 9
0
        /**
     * Adds a new OLE Package Shape 
     * 
     * @param anchor       the client anchor describes how this picture is
     *                     attached to the sheet.
     * @param storageId    the storageId returned by {@Link HSSFWorkbook.AddOlePackage}
     * @param pictureIndex the index of the picture (used as preview image) in the
     *                     workbook collection of pictures.
     *
     * @return newly Created shape
     */
        public HSSFObjectData CreateObjectData(HSSFClientAnchor anchor, int storageId, int pictureIndex)
        {
            ObjRecord obj = new ObjRecord();

            CommonObjectDataSubRecord ftCmo = new CommonObjectDataSubRecord();
            ftCmo.ObjectType = (/*setter*/CommonObjectType.Picture);
            // ftCmo.ObjectId=(/*setter*/oleShape.ShapeId); ... will be Set by onCreate(...)
            ftCmo.IsLocked = (/*setter*/true);
            ftCmo.IsPrintable = (/*setter*/true);
            ftCmo.IsAutoFill = (/*setter*/true);
            ftCmo.IsAutoline = (/*setter*/true);
            ftCmo.Reserved1 = (/*setter*/0);
            ftCmo.Reserved2 = (/*setter*/0);
            ftCmo.Reserved3 = (/*setter*/0);
            obj.AddSubRecord(ftCmo);

            // FtCf (pictFormat) 
            FtCfSubRecord ftCf = new FtCfSubRecord();
            HSSFPictureData pictData = Sheet.Workbook.GetAllPictures()[(pictureIndex - 1)] as HSSFPictureData;
            switch ((PictureType)pictData.Format)
            {
                case PictureType.WMF:
                case PictureType.EMF:
                    // this needs patch #49658 to be applied to actually work 
                    ftCf.Flags = (/*setter*/FtCfSubRecord.METAFILE_BIT);
                    break;
                case PictureType.DIB:
                case PictureType.PNG:
                case PictureType.JPEG:
                case PictureType.PICT:
                    ftCf.Flags = (/*setter*/FtCfSubRecord.BITMAP_BIT);
                    break;
            }
            obj.AddSubRecord(ftCf);
            // FtPioGrbit (pictFlags)
            FtPioGrbitSubRecord ftPioGrbit = new FtPioGrbitSubRecord();
            ftPioGrbit.SetFlagByBit(FtPioGrbitSubRecord.AUTO_PICT_BIT, true);
            obj.AddSubRecord(ftPioGrbit);

            EmbeddedObjectRefSubRecord ftPictFmla = new EmbeddedObjectRefSubRecord();
            ftPictFmla.SetUnknownFormulaData(new byte[] { 2, 0, 0, 0, 0 });
            ftPictFmla.OLEClassName = (/*setter*/"Paket");
            ftPictFmla.SetStorageId(storageId);

            obj.AddSubRecord(ftPictFmla);
            obj.AddSubRecord(new EndSubRecord());

            String entryName = "MBD" + HexDump.ToHex(storageId);
            DirectoryEntry oleRoot;
            try
            {
                DirectoryNode dn = (_sheet.Workbook as HSSFWorkbook).RootDirectory;
                if (dn == null) throw new FileNotFoundException();
                oleRoot = (DirectoryEntry)dn.GetEntry(entryName);
            }
            catch (FileNotFoundException e)
            {
                throw new InvalidOperationException("trying to add ole shape without actually Adding data first - use HSSFWorkbook.AddOlePackage first", e);
            }

            // create picture shape, which need to be minimal modified for oleshapes
            HSSFPicture shape = new HSSFPicture(null, anchor);
            shape.PictureIndex = (/*setter*/pictureIndex);
            EscherContainerRecord spContainer = shape.GetEscherContainer();
            EscherSpRecord spRecord = spContainer.GetChildById(EscherSpRecord.RECORD_ID) as EscherSpRecord;
            spRecord.Flags = (/*setter*/spRecord.Flags | EscherSpRecord.FLAG_OLESHAPE);

            HSSFObjectData oleShape = new HSSFObjectData(spContainer, obj, oleRoot);
            AddShape(oleShape);
            OnCreate(oleShape);


            return oleShape;
        }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
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;
 }
Ejemplo n.º 12
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=((short)(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);

        }
Ejemplo n.º 13
0
 protected override ObjRecord CreateObjRecord()
 {
     ObjRecord obj = new ObjRecord();
     CommonObjectDataSubRecord c = new CommonObjectDataSubRecord();
     c.ObjectType = CommonObjectType.ComboBox;
     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;
 }
Ejemplo n.º 14
0
        public override Object Clone()
        {
            ObjRecord rec = new ObjRecord();

            for (IEnumerator iterator = subrecords.GetEnumerator(); iterator.MoveNext(); )
                rec.AddSubRecord(((Record)iterator.Current).Clone());

            return rec;
        }
Ejemplo n.º 15
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    = ((short)(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);
        }
Ejemplo n.º 16
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;
        }
Ejemplo n.º 17
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;
        }