Example #1
0
        public void TestReadPICT()
        {
            //provided in bug-44886
            byte[] data = _samples.ReadFile("Container.dat");

            EscherContainerRecord record = new EscherContainerRecord();

            record.FillFields(data, 0, new DefaultEscherRecordFactory());
            EscherContainerRecord bstore = (EscherContainerRecord)record.ChildRecords[1];
            EscherBSERecord       bse1   = (EscherBSERecord)bstore.ChildRecords[1];

            //System.out.println(bse1);
            Assert.AreEqual(EscherBSERecord.BT_WMF, bse1.BlipTypeWin32);
            Assert.AreEqual(EscherBSERecord.BT_PICT, bse1.BlipTypeMacOS);
            Assert.IsTrue(Arrays.Equals(new byte[] {
                (byte)0xC7, 0x15, 0x69, 0x2D, (byte)0xE5, (byte)0x89, (byte)0xA3, 0x6F,
                0x66, 0x03, (byte)0xD6, 0x24, (byte)0xF7, (byte)0xDB, 0x1D, 0x13
            }, bse1.UID));
            Assert.AreEqual(255, bse1.Tag);
            Assert.AreEqual(1133, bse1.Size);

            EscherMetafileBlip blip1 = (EscherMetafileBlip)bse1.BlipRecord;

            Assert.AreEqual(0x5430, blip1.Options);
            Assert.AreEqual(EscherMetafileBlip.RECORD_ID_PICT, blip1.RecordId);
            Assert.IsTrue(Arrays.Equals(new byte[] {
                0x57, 0x32, 0x7B, (byte)0x91, 0x23, 0x5D, (byte)0xDB, 0x36,
                0x7A, (byte)0xDB, (byte)0xFF, 0x17, (byte)0xFE, (byte)0xF3, (byte)0xA7, 0x05
            }, blip1.UID));
            Assert.IsTrue(Arrays.Equals(new byte[] {
                (byte)0xC7, 0x15, 0x69, 0x2D, (byte)0xE5, (byte)0x89, (byte)0xA3, 0x6F,
                0x66, 0x03, (byte)0xD6, 0x24, (byte)0xF7, (byte)0xDB, 0x1D, 0x13
            }, blip1.PrimaryUID));

            //Serialize and Read again
            byte[]          ser  = bse1.Serialize();
            EscherBSERecord bse2 = new EscherBSERecord();

            bse2.FillFields(ser, 0, new DefaultEscherRecordFactory());
            Assert.AreEqual(bse1.RecordId, bse2.RecordId);
            Assert.AreEqual(bse1.Options, bse2.Options);
            Assert.AreEqual(bse1.BlipTypeWin32, bse2.BlipTypeWin32);
            Assert.AreEqual(bse1.BlipTypeMacOS, bse2.BlipTypeMacOS);
            Assert.IsTrue(Arrays.Equals(bse1.UID, bse2.UID));
            Assert.AreEqual(bse1.Tag, bse2.Tag);
            Assert.AreEqual(bse1.Size, bse2.Size);

            EscherMetafileBlip blip2 = (EscherMetafileBlip)bse1.BlipRecord;

            Assert.AreEqual(blip1.Options, blip2.Options);
            Assert.AreEqual(blip1.RecordId, blip2.RecordId);
            Assert.AreEqual(blip1.UID, blip2.UID);
            Assert.AreEqual(blip1.PrimaryUID, blip2.PrimaryUID);

            Assert.IsTrue(Arrays.Equals(blip1.PictureData, blip1.PictureData));
        }
Example #2
0
        protected override EscherContainerRecord CreateSpContainer()
        {
            EscherContainerRecord spContainer = base.CreateSpContainer();
            EscherOptRecord       opt         = (EscherOptRecord)spContainer.GetChildById(EscherOptRecord.RECORD_ID);

            opt.RemoveEscherProperty(EscherProperties.LINESTYLE__LINEDASHING);
            opt.RemoveEscherProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH);
            spContainer.RemoveChildRecord(spContainer.GetChildById(EscherTextboxRecord.RECORD_ID));
            return(spContainer);
        }
Example #3
0
        internal override HSSFShape CloneShape()
        {
            EscherContainerRecord spContainer = new EscherContainerRecord();

            byte[] inSp = GetEscherContainer().Serialize();
            spContainer.FillFields(inSp, 0, new DefaultEscherRecordFactory());
            ObjRecord obj = (ObjRecord)GetObjRecord().CloneViaReserialise();

            return(new HSSFPicture(spContainer, obj));
        }
Example #4
0
        internal override HSSFShape CloneShape()
        {
            TextObjectRecord      txo         = GetTextObjectRecord() == null ? null : (TextObjectRecord)GetTextObjectRecord().CloneViaReserialise();
            EscherContainerRecord spContainer = new EscherContainerRecord();

            byte[] inSp = GetEscherContainer().Serialize();
            spContainer.FillFields(inSp, 0, new DefaultEscherRecordFactory());
            ObjRecord obj = (ObjRecord)GetObjRecord().CloneViaReserialise();

            return(new HSSFTextbox(spContainer, obj, txo));
        }
Example #5
0
        public void TestContainer()
        {
            byte[] data = _samples.ReadFile("Container.dat");

            EscherContainerRecord record = new EscherContainerRecord();

            record.FillFields(data, 0, new DefaultEscherRecordFactory());

            byte[] ser = record.Serialize();
            Assert.IsTrue(Arrays.Equals(data, ser));
        }
Example #6
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();
        }
 private EscherRecord FindClientData(EscherContainerRecord spContainer)
 {
     for (IEnumerator iterator = spContainer.ChildRecords.GetEnumerator(); iterator.MoveNext();)
     {
         EscherRecord r = (EscherRecord)iterator.Current;
         if (r.RecordId == EscherClientDataRecord.RECORD_ID)
         {
             return(r);
         }
     }
     throw new ArgumentException("Can not Find client data record");
 }
 private EscherRecord GetEscherChild(EscherContainerRecord owner, int recordId)
 {
     for (IEnumerator iterator = owner.ChildRecords.GetEnumerator(); iterator.MoveNext();)
     {
         EscherRecord escherRecord = (EscherRecord)iterator.Current;
         if (escherRecord.RecordId == recordId)
         {
             return(escherRecord);
         }
     }
     return(null);
 }
Example #9
0
        internal override HSSFShape CloneShape()
        {
            TextObjectRecord      txo         = (TextObjectRecord)GetTextObjectRecord().CloneViaReserialise();
            EscherContainerRecord spContainer = new EscherContainerRecord();

            byte[] inSp = GetEscherContainer().Serialize();
            spContainer.FillFields(inSp, 0, new DefaultEscherRecordFactory());
            ObjRecord  obj  = (ObjRecord)GetObjRecord().CloneViaReserialise();
            NoteRecord note = (NoteRecord)NoteRecord.CloneViaReserialise();

            return(new HSSFComment(spContainer, obj, txo, note));
        }
Example #10
0
    public static Shape CreateSimpeShape(EscherContainerRecord spContainer, Shape parent){
        Shape shape = null;
        EscherSpRecord spRecord = spContainer.GetChildById(EscherSpRecord.RECORD_ID);

        int type = spRecord.GetOptions() >> 4;
        switch (type){
            case ShapeTypes.TextBox:
                shape = new TextBox(spContainer, parent);
                break;
            case ShapeTypes.HostControl:
            case ShapeTypes.PictureFrame: {
                InteractiveInfo info = (InteractiveInfo)getClientDataRecord(spContainer, RecordTypes.InteractiveInfo.typeID);
                OEShapeAtom oes = (OEShapeAtom)getClientDataRecord(spContainer, RecordTypes.OEShapeAtom.typeID);
                if(info != null && info.GetInteractiveInfoAtom() != null){
                    switch(info.GetInteractiveInfoAtom().GetAction()){
                        case InteractiveInfoAtom.ACTION_OLE:
                            shape = new OLEShape(spContainer, parent);
                            break;
                        case InteractiveInfoAtom.ACTION_MEDIA:
                            shape = new MovieShape(spContainer, parent);
                            break;
                        default:
                            break;
                    }
                } else if (oes != null){
                    shape = new OLEShape(spContainer, parent);
                }

                if(shape == null) shape = new Picture(spContainer, parent);
                break;
            }
            case ShapeTypes.Line:
                shape = new Line(spContainer, parent);
                break;
            case ShapeTypes.NotPrimitive: {
                EscherOptRecord opt = (EscherOptRecord)Shape.GetEscherChild(spContainer, EscherOptRecord.RECORD_ID);
                EscherProperty prop = Shape.GetEscherProperty(opt, EscherProperties.GEOMETRY__VERTICES);
                if(prop != null)
                    shape = new Freeform(spContainer, parent);
                else {

                    logger.log(POILogger.WARN, "Creating AutoShape for a NotPrimitive shape");
                    shape = new AutoShape(spContainer, parent);
                }
                break;
            }
            default:
                shape = new AutoShape(spContainer, parent);
                break;
        }
        return shape;

    }
Example #11
0
File: Shape.cs Project: zzy092/npoi
 /**
  * Helper method to return escher child by record ID
  *
  * @return escher record or <code>null</code> if not found.
  */
 public static EscherRecord GetEscherChild(EscherContainerRecord owner, int recordId)
 {
     for (List <EscherRecord> .Enumerator iterator = owner.GetChildIterator(); iterator.MoveNext();)
     {
         EscherRecord escherRecord = iterator.Current;
         if (escherRecord.RecordId == recordId)
         {
             return(escherRecord);
         }
     }
     return(null);
 }
Example #12
0
        protected override EscherContainerRecord CreateSpContainer()
        {
            EscherContainerRecord spContainer = base.CreateSpContainer();
            EscherOptRecord       opt         = (EscherOptRecord)spContainer.GetChildById(EscherOptRecord.RECORD_ID);

            opt.RemoveEscherProperty(EscherProperties.TEXT__TEXTLEFT);
            opt.RemoveEscherProperty(EscherProperties.TEXT__TEXTRIGHT);
            opt.RemoveEscherProperty(EscherProperties.TEXT__TEXTTOP);
            opt.RemoveEscherProperty(EscherProperties.TEXT__TEXTBOTTOM);
            opt.SetEscherProperty(new EscherSimpleProperty(EscherProperties.GROUPSHAPE__PRINT, false, false, GROUP_SHAPE_PROPERTY_DEFAULT_VALUE));
            return(spContainer);
        }
Example #13
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(HSSFTextbox hssfShape, int shapeId)
        {
            HSSFTextbox shape = hssfShape;

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

            escherTextbox = new EscherTextboxRecord();

            spContainer.RecordId = EscherContainerRecord.SP_CONTAINER;
            spContainer.Options  = (short)0x000F;
            sp.RecordId          = EscherSpRecord.RECORD_ID;
            sp.Options           = (short)((EscherAggregate.ST_TEXTBOX << 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, 262144 ) );
            opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.TEXT__TEXTID, 0));
            opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.TEXT__TEXTLEFT, shape.MarginLeft));
            opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.TEXT__TEXTRIGHT, shape.MarginRight));
            opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.TEXT__TEXTBOTTOM, shape.MarginBottom));
            opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.TEXT__TEXTTOP, shape.MarginTop));

            opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.TEXT__WRAPTEXT, 0));
            opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.TEXT__ANCHORTEXT, 0));
            opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.GROUPSHAPE__PRINT, 0x00080000));

            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;
            escherTextbox.RecordId = EscherTextboxRecord.RECORD_ID;
            escherTextbox.Options  = (short)0x0000;

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

            return(spContainer);
        }
Example #14
0
        /**
         * Generates the shape records for this shape.
         */

        protected override EscherContainerRecord CreateSpContainer()
        {
            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_NOT_PRIMATIVE << 4) | 0x2));
            if (Parent == null)
            {
                sp.Flags = (EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE);
            }
            else
            {
                sp.Flags = (EscherSpRecord.FLAG_CHILD | EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE);
            }
            opt.RecordId = (EscherOptRecord.RECORD_ID);
            opt.SetEscherProperty(new EscherSimpleProperty(EscherProperties.TRANSFORM__ROTATION, false, false, 0));
            opt.SetEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__RIGHT, false, false, 100));
            opt.SetEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__BOTTOM, false, false, 100));
            opt.SetEscherProperty(new EscherShapePathProperty(EscherProperties.GEOMETRY__SHAPEPATH, EscherShapePathProperty.COMPLEX));

            opt.SetEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__FILLOK, false, false, 0x00010001));
            opt.SetEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINESTARTARROWHEAD, false, false, 0x0));
            opt.SetEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEENDARROWHEAD, false, false, 0x0));
            opt.SetEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEENDCAPSTYLE, false, false, 0x0));

            opt.SetEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEDASHING, LINESTYLE_SOLID));
            opt.SetEscherProperty(new EscherBoolProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x00080008));
            opt.SetEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEWIDTH, LINEWIDTH_DEFAULT));
            opt.SetEscherProperty(new EscherRGBProperty(EscherProperties.FILL__FILLCOLOR, FILL__FILLCOLOR_DEFAULT));
            opt.SetEscherProperty(new EscherRGBProperty(EscherProperties.LINESTYLE__COLOR, LINESTYLE__COLOR_DEFAULT));
            opt.SetEscherProperty(new EscherBoolProperty(EscherProperties.FILL__NOFILLHITTEST, 1));

            opt.SetEscherProperty(new EscherBoolProperty(EscherProperties.GROUPSHAPE__PRINT, 0x080000));

            EscherRecord anchor = Anchor.GetEscherAnchor();

            clientData.RecordId = (EscherClientDataRecord.RECORD_ID);
            clientData.Options  = ((short)0x0000);

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

            return(spContainer);
        }
        public void TestBug44857()
        {
            //File f = new File(ESCHER_DATA_PATH, "Container.dat");
            Assert.IsTrue(File.Exists(ESCHER_DATA_PATH + "Container.dat"));

            FileStream finp = new FileStream(ESCHER_DATA_PATH + "Container.dat", FileMode.Open, FileAccess.Read);

            byte[] data = IOUtils.ToByteArray(finp);
            finp.Close();
            // This used to fail with an OutOfMemory
            EscherContainerRecord record = new EscherContainerRecord();

            record.FillFields(data, 0, new DefaultEscherRecordFactory());
        }
Example #16
0
        private void OnCreate(HSSFShape shape)
        {
            EscherContainerRecord spgrContainer =
                _boundAggregate.GetEscherContainer().ChildContainers[0];

            EscherContainerRecord spContainer = shape.GetEscherContainer();
            int shapeId = NewShapeId();

            shape.ShapeId = shapeId;

            spgrContainer.AddChildRecord(spContainer);
            shape.AfterInsert(this);
            SetFlipFlags(shape);
        }
Example #17
0
        public void TestReadPNG()
        {
            //provided in bug-44886
            byte[] data = _samples.ReadFile("Container.dat");

            EscherContainerRecord record = new EscherContainerRecord();

            record.FillFields(data, 0, new DefaultEscherRecordFactory());
            EscherContainerRecord bstore = (EscherContainerRecord)record.ChildRecords[1];
            EscherBSERecord       bse1   = (EscherBSERecord)bstore.ChildRecords[0];

            Assert.AreEqual(EscherBSERecord.BT_PNG, bse1.BlipTypeWin32);
            Assert.AreEqual(EscherBSERecord.BT_PNG, bse1.BlipTypeMacOS);
            Assert.IsTrue(Arrays.Equals(new byte[] {
                0x65, 0x07, 0x4A, (byte)0x8D, 0x3E, 0x42, (byte)0x8B, (byte)0xAC,
                0x1D, (byte)0x89, 0x35, 0x4F, 0x48, (byte)0xFA, 0x37, (byte)0xC2
            }, bse1.UID));
            Assert.AreEqual(255, bse1.Tag);
            Assert.AreEqual(32308, bse1.Size);

            EscherBitmapBlip blip1 = (EscherBitmapBlip)bse1.BlipRecord;

            Assert.AreEqual(0x6E00, blip1.Options);
            Assert.AreEqual(EscherBitmapBlip.RECORD_ID_PNG, blip1.RecordId);
            Assert.IsTrue(Arrays.Equals(new byte[] {
                0x65, 0x07, 0x4A, (byte)0x8D, 0x3E, 0x42, (byte)0x8B, (byte)0xAC,
                0x1D, (byte)0x89, 0x35, 0x4F, 0x48, (byte)0xFA, 0x37, (byte)0xC2
            }, blip1.UID));

            //Serialize and Read again
            byte[]          ser  = bse1.Serialize();
            EscherBSERecord bse2 = new EscherBSERecord();

            bse2.FillFields(ser, 0, new DefaultEscherRecordFactory());
            Assert.AreEqual(bse1.RecordId, bse2.RecordId);
            Assert.AreEqual(bse1.BlipTypeWin32, bse2.BlipTypeWin32);
            Assert.AreEqual(bse1.BlipTypeMacOS, bse2.BlipTypeMacOS);
            Assert.IsTrue(Arrays.Equals(bse1.UID, bse2.UID));
            Assert.AreEqual(bse1.Tag, bse2.Tag);
            Assert.AreEqual(bse1.Size, bse2.Size);

            EscherBitmapBlip blip2 = (EscherBitmapBlip)bse1.BlipRecord;

            Assert.AreEqual(blip1.Options, blip2.Options);
            Assert.AreEqual(blip1.RecordId, blip2.RecordId);
            Assert.AreEqual(blip1.UID, blip2.UID);

            Assert.IsTrue(Arrays.Equals(blip1.PictureData, blip1.PictureData));
        }
Example #18
0
 public static HSSFAnchor CreateAnchorFromEscher(EscherContainerRecord container)
 {
     if (null != container.GetChildById(EscherChildAnchorRecord.RECORD_ID))
     {
         return(new HSSFChildAnchor((EscherChildAnchorRecord)container.GetChildById(EscherChildAnchorRecord.RECORD_ID)));
     }
     else
     {
         if (null != container.GetChildById(EscherClientAnchorRecord.RECORD_ID))
         {
             return(new HSSFClientAnchor((EscherClientAnchorRecord)container.GetChildById(EscherClientAnchorRecord.RECORD_ID)));
         }
         return(null);
     }
 }
Example #19
0
        internal override HSSFShape CloneShape()
        {
            TextObjectRecord      txo         = null;
            EscherContainerRecord spContainer = new EscherContainerRecord();

            byte[] inSp = GetEscherContainer().Serialize();
            spContainer.FillFields(inSp, 0, new DefaultEscherRecordFactory());
            ObjRecord obj = (ObjRecord)GetObjRecord().CloneViaReserialise();

            if (GetTextObjectRecord() != null && this.String != null && null != this.String.String)
            {
                txo = (TextObjectRecord)GetTextObjectRecord().CloneViaReserialise();
            }
            return(new HSSFSimpleShape(spContainer, obj, txo));
        }
Example #20
0
        public void TestShapeIds()
        {
            HSSFWorkbook  wb1        = new HSSFWorkbook();
            HSSFSheet     sheet1     = wb1.CreateSheet() as HSSFSheet;
            HSSFPatriarch patriarch1 = sheet1.CreateDrawingPatriarch() as HSSFPatriarch;

            for (int i = 0; i < 2; i++)
            {
                patriarch1.CreateSimpleShape(new HSSFClientAnchor());
            }

            HSSFWorkbook wb2 = HSSFTestDataSamples.WriteOutAndReadBack(wb1);

            wb1.Close();

            sheet1     = wb2.GetSheetAt(0) as HSSFSheet;
            patriarch1 = sheet1.DrawingPatriarch as HSSFPatriarch;

            EscherAggregate agg1 = HSSFTestHelper.GetEscherAggregate(patriarch1);
            // last shape ID cached in EscherDgRecord
            EscherDgRecord dg1 =
                agg1.GetEscherContainer().GetChildById(EscherDgRecord.RECORD_ID) as EscherDgRecord;

            Assert.AreEqual(1026, dg1.LastMSOSPID);

            // iterate over shapes and check shapeId
            EscherContainerRecord spgrContainer =
                agg1.GetEscherContainer().ChildContainers[0] as EscherContainerRecord;

            // root spContainer + 2 spContainers for shapes
            Assert.AreEqual(3, spgrContainer.ChildRecords.Count);

            EscherSpRecord sp0 =
                ((EscherContainerRecord)spgrContainer.GetChild(0)).GetChildById(EscherSpRecord.RECORD_ID) as EscherSpRecord;

            Assert.AreEqual(1024, sp0.ShapeId);

            EscherSpRecord sp1 =
                ((EscherContainerRecord)spgrContainer.GetChild(1)).GetChildById(EscherSpRecord.RECORD_ID) as EscherSpRecord;

            Assert.AreEqual(1025, sp1.ShapeId);

            EscherSpRecord sp2 =
                ((EscherContainerRecord)spgrContainer.GetChild(2)).GetChildById(EscherSpRecord.RECORD_ID) as EscherSpRecord;

            Assert.AreEqual(1026, sp2.ShapeId);
            wb2.Close();
        }
Example #21
0
        protected override EscherContainerRecord CreateSpContainer()
        {
            EscherContainerRecord  spContainer   = new EscherContainerRecord();
            EscherSpRecord         sp            = new EscherSpRecord();
            EscherOptRecord        opt           = new EscherOptRecord();
            EscherClientDataRecord clientData    = new EscherClientDataRecord();
            EscherTextboxRecord    escherTextbox = new EscherTextboxRecord();

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

            sp.Flags     = (EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE);
            opt.RecordId = (EscherOptRecord.RECORD_ID);
            opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.TEXT__TEXTID, 0));
            opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.TEXT__WRAPTEXT, 0));
            opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.TEXT__ANCHORTEXT, 0));
            opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.GROUPSHAPE__PRINT, 0x00080000));

            opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.TEXT__TEXTLEFT, 0));
            opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.TEXT__TEXTRIGHT, 0));
            opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.TEXT__TEXTTOP, 0));
            opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.TEXT__TEXTBOTTOM, 0));

            opt.SetEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEDASHING, LINESTYLE_SOLID));
            opt.SetEscherProperty(new EscherBoolProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x00080008));
            opt.SetEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEWIDTH, LINEWIDTH_DEFAULT));
            opt.SetEscherProperty(new EscherRGBProperty(EscherProperties.FILL__FILLCOLOR, FILL__FILLCOLOR_DEFAULT));
            opt.SetEscherProperty(new EscherRGBProperty(EscherProperties.LINESTYLE__COLOR, LINESTYLE__COLOR_DEFAULT));
            opt.SetEscherProperty(new EscherBoolProperty(EscherProperties.FILL__NOFILLHITTEST, NO_FILLHITTEST_FALSE));
            opt.SetEscherProperty(new EscherBoolProperty(EscherProperties.GROUPSHAPE__PRINT, 0x080000));

            EscherRecord anchor = Anchor.GetEscherAnchor();

            clientData.RecordId    = (EscherClientDataRecord.RECORD_ID);
            clientData.Options     = ((short)0x0000);
            escherTextbox.RecordId = (EscherTextboxRecord.RECORD_ID);
            escherTextbox.Options  = ((short)0x0000);

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

            return(spContainer);
        }
Example #22
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);
        }
Example #23
0
        public void TestSerialize()
        {
            EscherContainerRecord  container1   = new EscherContainerRecord();
            EscherContainerRecord  spContainer1 = new EscherContainerRecord();
            EscherContainerRecord  spContainer2 = new EscherContainerRecord();
            EscherContainerRecord  spContainer3 = new EscherContainerRecord();
            EscherSpRecord         sp1          = new EscherSpRecord();
            EscherSpRecord         sp2          = new EscherSpRecord();
            EscherSpRecord         sp3          = new EscherSpRecord();
            EscherClientDataRecord d2           = new EscherClientDataRecord();
            EscherClientDataRecord d3           = new EscherClientDataRecord();

            container1.Options    = ((short)0x000F);
            spContainer1.Options  = ((short)0x000F);
            spContainer1.RecordId = (EscherContainerRecord.SP_CONTAINER);
            spContainer2.Options  = ((short)0x000F);
            spContainer2.RecordId = (EscherContainerRecord.SP_CONTAINER);
            spContainer3.Options  = ((short)0x000F);
            spContainer3.RecordId = (EscherContainerRecord.SP_CONTAINER);
            d2.RecordId           = (EscherClientDataRecord.RECORD_ID);
            d2.RemainingData      = (new byte[0]);
            d3.RecordId           = (EscherClientDataRecord.RECORD_ID);
            d3.RemainingData      = (new byte[0]);
            container1.AddChildRecord(spContainer1);
            container1.AddChildRecord(spContainer2);
            container1.AddChildRecord(spContainer3);
            spContainer1.AddChildRecord(sp1);
            spContainer2.AddChildRecord(sp2);
            spContainer3.AddChildRecord(sp3);
            spContainer2.AddChildRecord(d2);
            spContainer3.AddChildRecord(d3);

            EscherAggregate aggregate = new EscherAggregate(null);

            aggregate.AddEscherRecord(container1);
            aggregate.AssoicateShapeToObjRecord(d2, new ObjRecord());
            aggregate.AssoicateShapeToObjRecord(d3, new ObjRecord());

            byte[] data         = new byte[112];
            int    bytesWritten = aggregate.Serialize(0, data);

            Assert.AreEqual(112, bytesWritten);
            Assert.AreEqual("[EC, 00, 40, 00, 0F, 00, 00, 00, 58, 00, 00, 00, 0F, 00, 04, F0, 10, 00, 00, 00, 00, 00, 0A, F0, 08, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 0F, 00, 04, F0, 18, 00, 00, 00, 00, 00, 0A, F0, 08, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 11, F0, 00, 00, 00, 00, 5D, 00, 00, 00, EC, 00, 20, 00, 0F, 00, 04, F0, 18, 00, 00, 00, 00, 00, 0A, F0, 08, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 11, F0, 00, 00, 00, 00, 5D, 00, 00, 00, ]",
                            HexDump.ToHex(data));
        }
Example #24
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);
        }
Example #25
0
        protected override EscherContainerRecord CreateSpContainer()
        {
            EscherContainerRecord spContainer = new EscherContainerRecord();

            spContainer.RecordId = EscherContainerRecord.SP_CONTAINER;
            spContainer.Options  = ((short)0x000F);

            EscherSpRecord sp = new EscherSpRecord();

            sp.RecordId = (EscherSpRecord.RECORD_ID);
            sp.Flags    = (EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE);
            sp.Version  = ((short)0x2);

            EscherClientDataRecord clientData = new EscherClientDataRecord();

            clientData.RecordId = (EscherClientDataRecord.RECORD_ID);
            clientData.Options  = ((short)(0x0000));

            EscherOptRecord optRecord = new EscherOptRecord();

            optRecord.SetEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEDASHING, LINESTYLE_SOLID));
            optRecord.SetEscherProperty(new EscherBoolProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x00080008));
            //        optRecord.SetEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEWIDTH, LINEWIDTH_DEFAULT));
            optRecord.SetEscherProperty(new EscherRGBProperty(EscherProperties.FILL__FILLCOLOR, FILL__FILLCOLOR_DEFAULT));
            optRecord.SetEscherProperty(new EscherRGBProperty(EscherProperties.LINESTYLE__COLOR, LINESTYLE__COLOR_DEFAULT));
            optRecord.SetEscherProperty(new EscherBoolProperty(EscherProperties.FILL__NOFILLHITTEST, NO_FILLHITTEST_FALSE));
            optRecord.SetEscherProperty(new EscherBoolProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x00080008));

            optRecord.SetEscherProperty(new EscherShapePathProperty(EscherProperties.GEOMETRY__SHAPEPATH, EscherShapePathProperty.COMPLEX));
            optRecord.SetEscherProperty(new EscherBoolProperty(EscherProperties.GROUPSHAPE__PRINT, 0x080000));
            optRecord.RecordId = EscherOptRecord.RECORD_ID;

            EscherTextboxRecord escherTextbox = new EscherTextboxRecord();

            escherTextbox.RecordId = (EscherTextboxRecord.RECORD_ID);
            escherTextbox.Options  = (short)0x0000;

            spContainer.AddChildRecord(sp);
            spContainer.AddChildRecord(optRecord);
            spContainer.AddChildRecord(this.Anchor.GetEscherAnchor());
            spContainer.AddChildRecord(clientData);
            spContainer.AddChildRecord(escherTextbox);
            return(spContainer);
        }
Example #26
0
        /**
         * Create a new Shape
         *
         * @param isChild   <code>true</code> if the Line is inside a group, <code>false</code> otherwise
         * @return the record Container which holds this shape
         */
        protected EscherContainerRecord CreateSpContainer(bool IsChild)
        {
            _escherContainer = new EscherContainerRecord();
            _escherContainer.SetRecordId(EscherContainerRecord.SP_CONTAINER);
            _escherContainer.SetOptions((short)15);

            EscherSpRecord sp    = new EscherSpRecord();
            int            flags = EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE;

            if (isChild)
            {
                flags |= EscherSpRecord.FLAG_CHILD;
            }
            sp.SetFlags(flags);
            _escherContainer.AddChildRecord(sp);

            EscherOptRecord opt = new EscherOptRecord();

            opt.SetRecordId(EscherOptRecord.RECORD_ID);
            _escherContainer.AddChildRecord(opt);

            EscherRecord anchor;

            if (isChild)
            {
                anchor = new EscherChildAnchorRecord();
            }
            else
            {
                anchor = new EscherClientAnchorRecord();

                //hack. internal variable EscherClientAnchorRecord.shortRecord can be
                //Initialized only in FillFields(). We need to Set shortRecord=false;
                byte[] header = new byte[16];
                LittleEndian.PutUshort(header, 0, 0);
                LittleEndian.PutUshort(header, 2, 0);
                LittleEndian.PutInt(header, 4, 8);
                anchor.FillFields(header, 0, null);
            }
            _escherContainer.AddChildRecord(anchor);

            return(_escherContainer);
        }
Example #27
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);
        }
Example #28
0
        /**
         * create shape tree from existing escher records tree
         */
        public void BuildShapeTree()
        {
            EscherContainerRecord dgContainer = _boundAggregate.GetEscherContainer();

            if (dgContainer == null)
            {
                return;
            }
            EscherContainerRecord         spgrConrainer = dgContainer.ChildContainers[0];
            IList <EscherContainerRecord> spgrChildren  = spgrConrainer.ChildContainers;

            for (int i = 0; i < spgrChildren.Count; i++)
            {
                EscherContainerRecord spContainer = spgrChildren[i];
                if (i != 0)
                {
                    HSSFShapeFactory.CreateShapeTree(spContainer, _boundAggregate, this, ((HSSFWorkbook)_sheet.Workbook).RootDirectory);
                }
            }
        }
Example #29
0
 private void OnCreate(HSSFShape shape)
 {
     if (this.Patriarch != null)
     {
         EscherContainerRecord spContainer = shape.GetEscherContainer();
         int shapeId = this.Patriarch.NewShapeId();
         shape.ShapeId = (shapeId);
         GetEscherContainer().AddChildRecord(spContainer);
         shape.AfterInsert(Patriarch);
         EscherSpRecord sp;
         if (shape is HSSFShapeGroup)
         {
             sp = (EscherSpRecord)shape.GetEscherContainer().ChildContainers[0].GetChildById(EscherSpRecord.RECORD_ID);
         }
         else
         {
             sp = (EscherSpRecord)shape.GetEscherContainer().GetChildById(EscherSpRecord.RECORD_ID);
         }
         sp.Flags = sp.Flags | EscherSpRecord.FLAG_CHILD;
     }
 }
Example #30
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
        }
        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 );
        }
Example #32
0
    public static ShapeGroup CreateShapeGroup(EscherContainerRecord spContainer, Shape parent){
        ShapeGroup group = null;
        EscherRecord opt = Shape.GetEscherChild((EscherContainerRecord)spContainer.GetChild(0), (short)0xF122);
        if(opt != null){
            try {
                EscherPropertyFactory f = new EscherPropertyFactory();
                List props = f.CreateProperties( opt.Serialize(), 8, opt.GetInstance() );
                EscherSimpleProperty p = (EscherSimpleProperty)props.Get(0);
                if(p.GetPropertyNumber() == 0x39F && p.GetPropertyValue() == 1){
                    group = new Table(spContainer, parent);
                } else {
                    group = new ShapeGroup(spContainer, parent);
                }
            } catch (Exception e){
                logger.log(POILogger.WARN, e.GetMessage());
                group = new ShapeGroup(spContainer, parent);
            }
        }  else {
            group = new ShapeGroup(spContainer, parent);
        }

        return group;
     }
Example #33
0
 protected Background(EscherContainerRecord escherRecord, Shape parent) {
     base(escherRecord, parent);
 }
Example #34
0
 protected static Record GetClientDataRecord(EscherContainerRecord spContainer, int recordType) {
     Record oep = null;
     for (Iterator<EscherRecord> it = spContainer.GetChildIterator(); it.HasNext();) {
         EscherRecord obj = it.next();
         if (obj.GetRecordId() == EscherClientDataRecord.RECORD_ID) {
             byte[] data = obj.Serialize();
             Record[] records = Record.FindChildRecords(data, 8, data.Length - 8);
             for (int j = 0; j < records.Length; j++) {
                 if (records[j].GetRecordType() == recordType) {
                     return records[j];
                 }
             }
         }
     }
     return oep;
 }
Example #35
0
    /**
     * Create a new ShapeGroup and create an instance of <code>EscherSpgrContainer</code> which represents a group of shapes
     */
    protected EscherContainerRecord CreateSpContainer(bool IsChild) {
        EscherContainerRecord spgr = new EscherContainerRecord();
        spgr.SetRecordId(EscherContainerRecord.SPGR_CONTAINER);
        spgr.SetOptions((short)15);

        //The group itself is a shape, and always appears as the first EscherSpContainer in the group Container.
        EscherContainerRecord spcont = new EscherContainerRecord();
        spcont.SetRecordId(EscherContainerRecord.SP_CONTAINER);
        spcont.SetOptions((short)15);

        EscherSpgrRecord spg = new EscherSpgrRecord();
        spg.SetOptions((short)1);
        spcont.AddChildRecord(spg);

        EscherSpRecord sp = new EscherSpRecord();
        short type = (ShapeTypes.NotPrimitive << 4) + 2;
        sp.SetOptions(type);
        sp.SetFlags(EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_GROUP);
        spcont.AddChildRecord(sp);

        EscherClientAnchorRecord anchor = new EscherClientAnchorRecord();
        spcont.AddChildRecord(anchor);

        spgr.AddChildRecord(spcont);
        return spgr;
    }
Example #36
0
 /**
   * Create a ShapeGroup object and Initilize it from the supplied Record Container.
   *
   * @param escherRecord       <code>EscherSpContainer</code> Container which holds information about this shape
   * @param parent    the parent of the shape
   */
 protected ShapeGroup(EscherContainerRecord escherRecord, Shape parent){
     base(escherRecord, parent);
 }
Example #37
0
  /**
   * Create a TableCell object and Initialize it from the supplied Record Container.
   *
   * @param escherRecord       <code>EscherSpContainer</code> Container which holds information about this shape
   * @param parent    the parent of the shape
   */
 protected TableCell(EscherContainerRecord escherRecord, Shape parent){
      base(escherRecord, parent);
  }
Example #38
0
 /**
  * Create a new shape from the data provided.
  */
 public static Shape CreateShape(EscherContainerRecord spContainer, Shape parent){
     if (spContainer.GetRecordId() == EscherContainerRecord.SPGR_CONTAINER){
         return CreateShapeGroup(spContainer, parent);
     }
     return CreateSimpeShape(spContainer, parent);
 }
Example #39
0
 /**
  * Create a Table object and Initilize it from the supplied Record Container.
  *
  * @param escherRecord <code>EscherSpContainer</code> Container which holds information about this shape
  * @param parent       the parent of the shape
  */
 public Table(EscherContainerRecord escherRecord, Shape parent) {
     base(escherRecord, parent);
 }
Example #40
0
 protected Line(EscherContainerRecord escherRecord, Shape parent){
     base(escherRecord, parent);
 }
Example #41
0
    /**
     * Create a TextBox object and Initialize it from the supplied Record Container.
     *
     * @param escherRecord       <code>EscherSpContainer</code> Container which holds information about this shape
     * @param parent    the parent of the shape
     */
   protected TextBox(EscherContainerRecord escherRecord, Shape parent){
        base(escherRecord, parent);

    }
Example #42
0
    /**
     * Create a Freeform object and Initialize it from the supplied Record Container.
     *
     * @param escherRecord       <code>EscherSpContainer</code> Container which holds information about this shape
     * @param parent    the parent of the shape
     */
   protected Freeform(EscherContainerRecord escherRecord, Shape parent){
        base(escherRecord, parent);

    }
Example #43
0
 protected Placeholder(EscherContainerRecord escherRecord, Shape parent){
     base(escherRecord, parent);
 }
Example #44
0
    /**
     * Create a Polygon object and Initialize it from the supplied Record Container.
     *
     * @param escherRecord       <code>EscherSpContainer</code> Container which holds information about this shape
     * @param parent    the parent of the shape
     */
   protected Polygon(EscherContainerRecord escherRecord, Shape parent){
        base(escherRecord, parent);

    }