Beispiel #1
0
 /// <summary>
 /// Creates the patriarch.
 /// </summary>
 /// <param name="sheet">the sheet this patriarch is stored in.</param>
 /// <param name="boundAggregate">The bound aggregate.</param>
 public HSSFPatriarch(HSSFSheet sheet, EscherAggregate boundAggregate)
 {
     _boundAggregate = boundAggregate;
     _sheet = sheet;
     _mainSpgrContainer = _boundAggregate.GetEscherContainer().ChildContainers[0];
     EscherContainerRecord spContainer = (EscherContainerRecord)_boundAggregate.GetEscherContainer()
             .ChildContainers[0].GetChild(0);
     _spgrRecord = (EscherSpgrRecord)spContainer.GetChildById(EscherSpgrRecord.RECORD_ID);
     BuildShapeTree();
 }
Beispiel #2
0
        protected override EscherContainerRecord CreateSpContainer()
        {
            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 = (0);
            spgr.RectY1 = (0);
            spgr.RectX2 = (1023);
            spgr.RectY2 = (255);
            sp.RecordId = (EscherSpRecord.RECORD_ID);
            sp.Options = (short)0x0002;
            if (this.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 = Anchor.GetEscherAnchor();
            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);
            return spgrContainer;
        }
        public void TestFillFields()
        {
            String hexData = "10 00 " +
                    "09 F0 " +
                    "10 00 00 00 " +
                    "01 00 00 00 " +
                    "02 00 00 00 " +
                    "03 00 00 00 " +
                    "04 00 00 00 ";
            byte[] data = HexRead.ReadFromString(hexData);
            EscherSpgrRecord r = new EscherSpgrRecord();
            int bytesWritten = r.FillFields(data, new DefaultEscherRecordFactory());

            Assert.AreEqual(24, bytesWritten);
            Assert.AreEqual(1, r.RectX1);
            Assert.AreEqual(2, r.RectY1);
            Assert.AreEqual(3, r.RectX2);
            Assert.AreEqual(4, r.RectY2);
        }
Beispiel #4
0
 public HSSFShapeGroup(EscherContainerRecord spgrContainer, ObjRecord objRecord)
     : base(spgrContainer, objRecord)
 {
     // read internal and external coordinates from spgrContainer
     EscherContainerRecord spContainer = spgrContainer.ChildContainers[0];
     _spgrRecord = (EscherSpgrRecord)spContainer.GetChild(0);
     foreach (EscherRecord ch in spContainer.ChildRecords)
     {
         switch (ch.RecordId)
         {
             case EscherSpgrRecord.RECORD_ID:
                 break;
             case EscherClientAnchorRecord.RECORD_ID:
                 anchor = new HSSFClientAnchor((EscherClientAnchorRecord)ch);
                 break;
             case EscherChildAnchorRecord.RECORD_ID:
                 anchor = new HSSFChildAnchor((EscherChildAnchorRecord)ch);
                 break;
         }
     }
 }
Beispiel #5
0
        /**
         * create base tree with such structure:
         * EscherDgContainer
         * -EscherSpgrContainer
         * --EscherSpContainer
         * ---EscherSpRecord
         * ---EscherSpgrRecord
         * ---EscherSpRecord
         * -EscherDgRecord
         *
         * id of DgRecord and SpRecord are empty and must be set later by HSSFPatriarch
         */
        private void BuildBaseTree()
        {
            EscherContainerRecord dgContainer = new EscherContainerRecord();
            EscherContainerRecord spgrContainer = new EscherContainerRecord();
            EscherContainerRecord spContainer1 = new EscherContainerRecord();
            EscherSpgrRecord spgr = new EscherSpgrRecord();
            EscherSpRecord sp1 = new EscherSpRecord();
            dgContainer.RecordId = (EscherContainerRecord.DG_CONTAINER);
            dgContainer.Options = ((short)0x000F);
            EscherDgRecord dg = new EscherDgRecord();
            dg.RecordId = EscherDgRecord.RECORD_ID;
            short dgId = 1;
            dg.Options = ((short)(dgId << 4));
            dg.NumShapes = (0);
            dg.LastMSOSPID=(1024);
            spgrContainer.RecordId=(EscherContainerRecord.SPGR_CONTAINER);
            spgrContainer.Options=((short)0x000F);
            spContainer1.RecordId=(EscherContainerRecord.SP_CONTAINER);
            spContainer1.Options=((short)0x000F);
            spgr.RecordId=(EscherSpgrRecord.RECORD_ID);
            spgr.Options=((short)0x0001);    // version
            spgr.RectX1=(0);
            spgr.RectY1=(0);
            spgr.RectX2=(1023);
            spgr.RectY2=(255);
            sp1.RecordId=(EscherSpRecord.RECORD_ID);

            sp1.Options=((short)0x0002);
            sp1.Version=((short)0x2);
            sp1.ShapeId=(-1);
            sp1.Flags=(EscherSpRecord.FLAG_GROUP | EscherSpRecord.FLAG_PATRIARCH);
            dgContainer.AddChildRecord(dg);
            dgContainer.AddChildRecord(spgrContainer);
            spgrContainer.AddChildRecord(spContainer1);
            spContainer1.AddChildRecord(spgr);
            spContainer1.AddChildRecord(sp1);
            AddEscherRecord(dgContainer);
        }
 private EscherSpgrRecord CreateRecord()
 {
     EscherSpgrRecord r = new EscherSpgrRecord();
     r.Options=(short)0x0010;
     r.RecordId=EscherSpgrRecord.RECORD_ID;
     r.RectX1=1;
     r.RectY1=2;
     r.RectX2=3;
     r.RectY2=4;
     return r;
 }
Beispiel #7
0
 public HSSFShapeGroup(HSSFShape parent, HSSFAnchor anchor)
     : base(parent, anchor)
 {
     _spgrRecord = (EscherSpgrRecord)((EscherContainerRecord)GetEscherContainer().GetChild(0)).GetChildById(EscherSpgrRecord.RECORD_ID);
 }
        private void ConvertPatriarch(HSSFPatriarch patriarch)
        {
            EscherContainerRecord dgContainer = new EscherContainerRecord();
            EscherDgRecord dg;
            EscherContainerRecord spgrContainer = new EscherContainerRecord();
            EscherContainerRecord spContainer1 = new EscherContainerRecord();
            EscherSpgrRecord spgr = new EscherSpgrRecord();
            EscherSpRecord sp1 = new EscherSpRecord();

            dgContainer.RecordId=EscherContainerRecord.DG_CONTAINER;
            dgContainer.Options=(short)0x000F;
            dg = drawingManager.CreateDgRecord();
            drawingGroupId = dg.DrawingGroupId;
            //        dg.Options( (short) ( drawingId << 4 ) );
            //        dg.NumShapes( GetNumberOfShapes( patriarch ) );
            //        dg.LastMSOSPID( 0 );  // populated after all shape id's are assigned.
            spgrContainer.RecordId=EscherContainerRecord.SPGR_CONTAINER;
            spgrContainer.Options=(short)0x000F;
            spContainer1.RecordId=EscherContainerRecord.SP_CONTAINER;
            spContainer1.Options=(short)0x000F;
            spgr.RecordId=EscherSpgrRecord.RECORD_ID;
            spgr.Options=(short)0x0001;    // version
            spgr.RectX1=patriarch.X1;
            spgr.RectY1=patriarch.Y1;
            spgr.RectX2=patriarch.X2;
            spgr.RectY2=patriarch.Y2;
            sp1.RecordId=EscherSpRecord.RECORD_ID;
            sp1.Options=(short)0x0002;
            sp1.ShapeId=drawingManager.AllocateShapeId(dg.DrawingGroupId);
            sp1.Flags=EscherSpRecord.FLAG_GROUP | EscherSpRecord.FLAG_PATRIARCH;

            dgContainer.AddChildRecord(dg);
            dgContainer.AddChildRecord(spgrContainer);
            spgrContainer.AddChildRecord(spContainer1);
            spContainer1.AddChildRecord(spgr);
            spContainer1.AddChildRecord(sp1);

            AddEscherRecord(dgContainer);
        }
        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);

        }