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

        //    FtCblsSubRecord f = new FtCblsSubRecord();

        //    LbsDataSubRecord l = LbsDataSubRecord.CreateAutoFilterInstance();

        //    EndSubRecord e = new EndSubRecord();

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

        //    return obj;
        //}

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

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

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

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

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

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

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

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

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

            return spContainer;
        }
예제 #3
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;
        }
예제 #4
0
 /**
  * creates shapes from existing file
  * @param spContainer
  * @param objRecord
  */
 public HSSFShape(EscherContainerRecord spContainer, ObjRecord objRecord)
 {
     this._escherContainer = spContainer;
     this._objRecord = objRecord;
     this._optRecord = (EscherOptRecord)spContainer.GetChildById(EscherOptRecord.RECORD_ID);
     this.anchor = HSSFAnchor.CreateAnchorFromEscher(spContainer);
 }
예제 #5
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;
        }
예제 #6
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;
        }
예제 #7
0
파일: HSSFShapeGroup.cs 프로젝트: WPG/npoi
        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;
        }
예제 #8
0
        private void CheckFillFieldsSimple()
        {
            String dataStr = "33 00 " + // options
                            "0B F0 " + // recordid
                            "12 00 00 00 " + // remaining bytes
                            "BF 00 08 00 08 00 " +
                            "81 01 09 00 00 08 " +
                            "C0 01 40 00 00 08";

            EscherOptRecord r = new EscherOptRecord();
            r.FillFields(HexRead.ReadFromString(dataStr), new DefaultEscherRecordFactory());
            Assert.AreEqual((short)0x0033, r.Options);
            Assert.AreEqual(unchecked((short)0xF00B), r.RecordId);
            Assert.AreEqual(3, r.EscherProperties.Count);
            EscherBoolProperty prop1 = new EscherBoolProperty(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 524296);
            EscherRGBProperty prop2 = new EscherRGBProperty(EscherProperties.FILL__FILLCOLOR, 0x08000009);
            EscherRGBProperty prop3 = new EscherRGBProperty(EscherProperties.LINESTYLE__COLOR, 0x08000040);
            Assert.AreEqual(prop1, r.GetEscherProperty(0));
            Assert.AreEqual(prop2, r.GetEscherProperty(1));
            Assert.AreEqual(prop3, r.GetEscherProperty(2));
        }
예제 #9
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;
        }
예제 #10
0
        private void CheckFillFieldsComplex()
        {
            String dataStr = "33 00 " +
                    "0B F0 " +
                    "14 00 00 00 " +
                    "BF 00 01 00 00 00 " +
                    "01 80 02 00 00 00 " +
                    "BF 00 01 00 00 00 " +
                    "01 02";

            EscherOptRecord r = new EscherOptRecord();
            r.FillFields(HexRead.ReadFromString(dataStr), new DefaultEscherRecordFactory());
            Assert.AreEqual((short)0x0033, r.Options);
            Assert.AreEqual(unchecked((short)0xF00B), r.RecordId);
            Assert.AreEqual(3, r.EscherProperties.Count);
            EscherBoolProperty prop1 = new EscherBoolProperty(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 1);
            EscherComplexProperty prop2 = new EscherComplexProperty((short)1, false, new byte[] { 0x01, 0x02 });
            EscherBoolProperty prop3 = new EscherBoolProperty(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 1);
            Assert.AreEqual(prop1, r.GetEscherProperty(0));
            Assert.AreEqual(prop2, r.GetEscherProperty(1));
            Assert.AreEqual(prop3, r.GetEscherProperty(2));

        }
예제 #11
0
파일: LineShape.cs 프로젝트: xoposhiy/npoi
        /// <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;
        }
예제 #12
0
파일: TextboxShape.cs 프로젝트: WPG/npoi
        /// <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;
        }
예제 #13
0
        public void TestEmptyArrayProperty()
        {
            EscherOptRecord r = new EscherOptRecord();
            EscherArrayProperty p = new EscherArrayProperty(unchecked((short)(EscherProperties.FILL__SHADECOLORS + 0x8000)), new byte[0]);
            Assert.AreEqual(0, p.NumberOfElementsInArray);
            r.AddEscherProperty(p);

            byte[] data1 = r.Serialize();
            EscherOptRecord opt2 = new EscherOptRecord();
            opt2.FillFields(data1, new DefaultEscherRecordFactory());
            p = (EscherArrayProperty)opt2.EscherProperties[0];
            Assert.AreEqual(0, p.NumberOfElementsInArray);

            byte[] data2 = opt2.Serialize();
            Assert.IsTrue(Arrays.Equals(data1, data2));
        }
예제 #14
0
        public void Test41946()
        {
            String dataStr1 =
                    "03 08 0B F0 00 03 00 00 81 00 30 65 01 00 82 00 98 B2 00 00 83 00 30 65 01 " +
                    "00 84 00 98 B2 00 00 85 00 00 00 00 00 87 00 01 00 00 00 88 00 00 00 00 00 " +
                    "89 00 00 00 00 00 BF 00 00 00 0F 00 0C 01 F4 00 00 10 0D 01 00 00 00 20 0E " +
                    "01 00 00 00 20 80 01 00 00 00 00 81 01 04 00 00 08 82 01 00 00 01 00 83 01 " +
                    "00 00 00 08 84 01 00 00 01 00 85 01 00 00 00 20 86 41 00 00 00 00 87 C1 00 " +
                    "00 00 00 88 01 00 00 00 00 89 01 00 00 00 00 8A 01 00 00 00 00 8B 01 00 00 " +
                    "00 00 8C 01 00 00 00 00 8D 01 00 00 00 00 8E 01 00 00 00 00 8F 01 00 00 00 " +
                    "00 90 01 00 00 00 00 91 01 00 00 00 00 92 01 00 00 00 00 93 01 00 00 00 00 " +
                    "94 01 00 00 00 00 95 01 00 00 00 00 96 01 00 00 00 00 97 C1 00 00 00 00 98 " +
                    "01 00 00 00 00 99 01 00 00 00 00 9A 01 00 00 00 00 9B 01 00 00 00 00 9C 01 " +
                    "03 00 00 40 BF 01 0C 00 1E 00 C0 01 01 00 00 08 C1 01 00 00 01 00 C2 01 FF " +
                    "FF FF 00 C3 01 00 00 00 20 C4 01 00 00 00 00 C5 41 00 00 00 00 C6 C1 00 00 " +
                    "00 00 C7 01 00 00 00 00 C8 01 00 00 00 00 C9 01 00 00 00 00 CA 01 00 00 00 " +
                    "00 CB 01 35 25 00 00 CC 01 00 00 08 00 CD 01 00 00 00 00 CE 01 00 00 00 00 " +
                    "CF C1 00 00 00 00 D7 01 02 00 00 00 FF 01 06 00 0E 00 00 02 00 00 00 00 01 " +
                    "02 02 00 00 08 02 02 CB CB CB 00 03 02 00 00 00 20 04 02 00 00 01 00 05 02 " +
                    "38 63 00 00 06 02 38 63 00 00 07 02 00 00 00 00 08 02 00 00 00 00 09 02 00 " +
                    "00 01 00 0A 02 00 00 00 00 0B 02 00 00 00 00 0C 02 00 00 01 00 0D 02 00 00 " +
                    "00 00 0E 02 00 00 00 00 0F 02 00 01 00 00 10 02 00 00 00 00 11 02 00 00 00 " +
                    "00 3F 02 00 00 03 00 80 02 00 00 00 00 81 02 00 00 01 00 82 02 05 00 00 00 " +
                    "83 02 9C 31 00 00 84 02 00 00 00 00 85 02 F0 F9 06 00 86 02 00 00 00 00 87 " +
                    "02 F7 00 00 10 88 02 00 00 00 20 BF 02 01 00 0F 00 C0 02 00 00 00 00 C1 02 " +
                    "00 00 00 00 C2 02 64 00 00 00 C3 02 00 00 00 00 C4 02 00 00 00 00 C5 02 00 " +
                    "00 00 00 C6 02 00 00 00 00 C7 02 00 00 00 00 C8 02 00 00 00 00 C9 02 00 00 " +
                    "00 00 CA 02 30 75 00 00 CB 02 D0 12 13 00 CC 02 30 ED EC FF CD 02 40 54 89 " +
                    "00 CE 02 00 80 00 00 CF 02 00 80 FF FF D0 02 00 00 79 FF D1 02 32 00 00 00 " +
                    "D2 02 20 4E 00 00 D3 02 50 C3 00 00 D4 02 00 00 00 00 D5 02 10 27 00 00 D6 " +
                    "02 70 94 00 00 D7 02 B0 3C FF FF D8 02 00 00 00 00 D9 02 10 27 00 00 DA 02 " +
                    "70 94 00 00 FF 02 16 00 1F 00 04 03 01 00 00 00 41 03 A8 29 01 00 42 03 00 " +
                    "00 00 00 43 03 03 00 00 00 44 03 7C BE 01 00 45 03 00 00 00 00 7F 03 00 00 " +
                    "0F 00 84 03 7C BE 01 00 85 03 00 00 00 00 86 03 7C BE 01 00 87 03 00 00 00 " +
                    "00";

            EscherOptRecord r = new EscherOptRecord();
            byte[] data = HexRead.ReadFromString(dataStr1);
            r.FillFields(data, 0, new DefaultEscherRecordFactory());
            Assert.AreEqual(unchecked((short)0xF00B), r.RecordId);

            byte[] data1 = r.Serialize();
            EscherOptRecord opt2 = new EscherOptRecord();
            opt2.FillFields(data1, new DefaultEscherRecordFactory());

            byte[] data2 = opt2.Serialize();
            Assert.IsTrue(Arrays.Equals(data1, data2));
        }
예제 #15
0
        public void TestComplexSerialise()
        {
            byte[] data = new byte[] {
    		0x53, 0x01, 0x0B, unchecked((byte)(0xF0-256)), unchecked((byte)(0x9C-256)), 0x01, 0x00, 0x00, 
    		// Simple data follows
    		0x42, 0x01,	0x49, 0x00, 0x00, 0x00,          // SP @ 8
    		0x43, 0x01, unchecked((byte)(0x85-256)), 0x00, 0x00, 0x00,      // SP @ 14
    		0x44, 0x01, 0x04, 0x00, 0x00, 0x00,          // SP @ 20
    		0x45, unchecked((byte)(0xC1-256)), unchecked((byte)(0x88-256)), 0x00, 0x00, 0x00,  // SP @ 26
    		0x46, unchecked((byte)(0xC1-256)), unchecked((byte)(0x90-256)), 0x00, 0x00, 0x00,  // SP @ 32
    		0x7F, 0x01, 0x01, 0x00, 0x01, 0x00, 
    		unchecked((byte)(0x80-256)), 0x01, 0x00, 0x00, 0x00, 0x00, 
    		unchecked((byte)(0x81-256)), 0x01, 0x02, 0x00, 0x00, 0x08, 
    		unchecked((byte)(0xBF-256)), 0x01,	0x10, 0x00, 0x10, 0x00, 
    		unchecked((byte)(0xC0-256)), 0x01, 0x01, 0x00, 0x00, 0x08,      // SP 10 
    		unchecked((byte)(0xC1-256)), 0x01, 0x00, 0x00, 0x01, 0x00,
    		unchecked((byte)(0xC4-256)), 0x01, 0x00, 0x00, 0x00, 0x00, 
    		unchecked((byte)(0xCB-256)), 0x01, 0x38, 0x63, 0x00, 0x00, 
    		unchecked((byte)(0xCD-256)), 0x01, 0x00, 0x00,	0x00, 0x00, 
    		unchecked((byte)(0xCE-256)), 0x01, 0x00, 0x00, 0x00, 0x00,      // SP 15
    		unchecked((byte)(0xD0-256)), 0x01, 0x00, 0x00, 0x00, 0x00, 
    		unchecked((byte)(0xD1-256)), 0x01, 0x00, 0x00, 0x00, 0x00, 
    		unchecked((byte)(0xD7-256)), 0x01, 0x00, 0x00, 0x00, 0x00, 
    		unchecked((byte)(0xFF-256)), 0x01, 0x18, 0x00, 0x18, 0x00,
    		0x01, 0x02, 0x02, 0x00, 0x00, 0x08, 
    		0x3F, 0x02, 0x00, 0x00,	0x02, 0x00,          // SP 21
    		
    		// Complex data follows
    		
    		// Complex data for Array #325
    		// Array header
    		0x22, 0x00, 0x22, 0x00, unchecked((byte)(0xF0-256)), unchecked((byte)(0xFF-256)), 
    		// Array data
    		0x18, 0x00, 0x28, 0x00, 0x04, 0x00, 0x34, 
    		0x00, 0x04, 0x00, 0x28, 0x00, 0x04, 0x00,
    		0x1C, 0x00, 0x04, 0x00, 0x10, 0x00, 0x04, 0x00, 0x04, 0x00, 0x10, 
    		0x00, 0x00, 0x00, 0x1C, 0x00,
    		0x04, 0x00, 0x28, 0x00, 0x10, 0x00, 0x34, 0x00, 0x18, 0x00, 0x3C, 
    		0x00, 0x24, 0x00, 0x44, 0x00,
    		0x30, 0x00, 0x48, 0x00, 0x3C, 0x00, 0x44, 0x00, 0x48, 0x00, 0x3C, 
    		0x00, 0x54, 0x00, 0x38, 0x00,
    		0x60, 0x00, 0x2C, 0x00, 0x70, 0x00, 0x20, 0x00, 0x78, 0x00, 
    		0x14, 0x00, unchecked((byte)(0x80-256)), 0x00, 0x08, 0x00,
    		unchecked((byte)(0x84-256)), 0x00, 0x04, 0x00, 0x78, 0x00, 0x04, 0x00, 0x6C, 0x00, 
    		0x04, 0x00, 0x60, 0x00, 0x04, 0x00,
    		0x54, 0x00, 0x08, 0x00, 0x48, 0x00, 0x0C, 0x00, 0x3C, 0x00, 0x0C, 
    		0x00, 0x30, 0x00, 0x08, 0x00,
    		0x3C, 0x00, 0x08, 0x00, 0x48, 0x00, 0x08, 0x00, 0x54, 0x00, 0x00, 
    		0x00, 0x48, 0x00, 0x00, 0x00,
    		0x3C, 0x00, 0x00, 0x00, 0x30, 0x00, 0x04, 0x00, 0x24, 0x00,
    		// Complex data for Array #326
    		// Array header
    		0x45, 0x00, 0x48, 0x00, 0x02, 0x00, 
    		// Array data
    		0x00, 0x40, 0x00, unchecked((byte)(0xB0-256)), 0x01, 0x00, 0x00, unchecked((byte)(0xB0-256)), 0x01, 0x00, 
    		0x00, unchecked((byte)(0xB0-256)), 0x01, 0x00, 0x00, unchecked((byte)(0xB0-256)),
    		0x01, 0x00, 0x00, unchecked((byte)(0xB0-256)), 0x01, 0x00, 0x00, unchecked((byte)(0xB0-256)), 0x01, 0x00, 
    		0x00, unchecked((byte)(0xB0-256)), 0x01, 0x00, 0x00, unchecked((byte)(0xB0-256)),
    		0x01, 0x00, 0x00, unchecked((byte)(0xB0-256)), 0x01, 0x00, 0x00, unchecked((byte)(0xB0-256)), 0x01, 0x00, 
    		0x00, unchecked((byte)(0xB0-256)), 0x01, 0x00, 0x00, unchecked((byte)(0xB0-256)),
    		0x01, 0x00, 0x00, unchecked((byte)(0xB0-256)), 0x01, 0x00, 0x00, unchecked((byte)(0xB0-256)), 0x01, 0x00, 
    		0x00, unchecked((byte)(0xB0-256)), 0x01, 0x00, 0x00, unchecked((byte)(0xB0-256)),
    		0x01, 0x00, 0x00, unchecked((byte)(0xB0-256)), 0x01, 0x00, 0x00, unchecked((byte)(0xB0-256)), 0x01, 0x00, 
    		0x00, unchecked((byte)(0xB0-256)), 0x01, 0x00, 0x00, unchecked((byte)(0xB0-256)),
    		0x01, 0x00, 0x00, unchecked((byte)(0xB0-256)), 0x01, 0x00, 0x00, unchecked((byte)(0xB0-256)), 0x01, 0x00, 
    		0x00, unchecked((byte)(0xB0-256)), 0x01, 0x00, 0x00, unchecked((byte)(0xB0-256)),
    		0x01, 0x00, 0x00, unchecked((byte)(0xB0-256)), 0x01, 0x00, 0x00,unchecked((byte)(0xB0-256)), 0x01, 0x00, 
    		0x00, unchecked((byte)(0xB0-256)), 0x01, 0x00, 0x00, unchecked((byte)(0xB0-256)),
    		0x01, 0x00, 0x00, unchecked((byte)(0xB0-256)), 0x01, 0x00, 0x00, unchecked((byte)(0xB0-256)), 0x01, 0x00, 
    		0x00, unchecked((byte)(0xB0-256)), 0x01, 0x00, 0x00, unchecked((byte)(0xB0-256)),
    		0x01, 0x00, 0x00, unchecked((byte)(0xB0-256)), 0x01, 0x00, 0x00, unchecked((byte)(0xB0-256)), 0x00, unchecked((byte)(0x80-256))
    	};

            // Create the record
            EscherOptRecord r = new EscherOptRecord();
            int Filled = r.FillFields(data, new DefaultEscherRecordFactory());

            // Check it's the right Length
            Assert.AreEqual(data.Length, Filled);
            Assert.AreEqual(data.Length, r.RecordSize);

            // Serialise it
            byte[] dest = new byte[data.Length];
            int written = r.Serialize(0, dest);

            // Check it serialised it back to the same data
            Assert.AreEqual(data.Length, written);
            for (int i = 0; i < data.Length; i++)
            {
                Assert.AreEqual(data[i], dest[i]);
            }
        }
예제 #16
0
 public void TestToString()
 {
     String nl = Environment.NewLine;
     EscherOptRecord r = new EscherOptRecord();
     r.Options=(short)0x000F;
     r.RecordId=EscherOptRecord.RECORD_ID;
     EscherProperty prop1 = new EscherBoolProperty((short)1, 1);
     r.AddEscherProperty(prop1);
     String expected = "EscherOptRecord:" + nl +
             "  isContainer: True" + nl +
             "  options: 0x0013" + nl +
             "  recordId: 0x" + HexDump.ToHex(EscherOptRecord.RECORD_ID) + nl +
             "  numchildren: 0" + nl +
             "  properties:" + nl +
             "    propNum: 1, RAW: 0x0001, propName: unknown, complex: False, blipId: False, value: 1 (0x00000001)" + nl;
     Assert.AreEqual(expected, r.ToString());
 }
예제 #17
0
        private void CheckSerializeSimple()
        {
            EscherOptRecord r = new EscherOptRecord();
            r.Options=(short)0x0033;
            r.RecordId=unchecked((short)0xF00B);
            EscherBoolProperty prop1 = new EscherBoolProperty(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 1);
            EscherRGBProperty prop2 = new EscherRGBProperty(EscherProperties.FILL__FILLCOLOR, 0x08000009);
            EscherRGBProperty prop3 = new EscherRGBProperty(EscherProperties.LINESTYLE__COLOR, 0x08000040);
            r.AddEscherProperty(prop1);
            r.AddEscherProperty(prop2);
            r.AddEscherProperty(prop3);

            byte[] data = new byte[26];
            int bytesWritten = r.Serialize(0, data);
            String dataStr = "[33, 00, " +
                    "0B, F0, " +
                    "12, 00, 00, 00, " +
                    "BF, 00, 01, 00, 00, 00, " +
                    "81, 01, 09, 00, 00, 08, " +
                    "C0, 01, 40, 00, 00, 08, ]";
            Assert.AreEqual(dataStr, HexDump.ToHex(data));
            Assert.AreEqual(26, bytesWritten);
        }
예제 #18
0
 /// <summary>
 /// Add standard properties to the opt record.  These properties effect
 /// all records.
 /// </summary>
 /// <param name="shape">The user model shape.</param>
 /// <param name="opt">The opt record to Add the properties to.</param>
 /// <returns>The number of options Added.</returns>
 protected virtual int AddStandardOptions(HSSFShape shape, EscherOptRecord opt)
 {
     opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 0x080000));
     //        opt.AddEscherProperty( new EscherBoolProperty( EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 0x080008 ) );
     if (shape.IsNoFill)
     {
         // Wonderful... none of the spec's give any clue as to what these constants mean.
         opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.Fill__NOFillHITTEST, 0x00110000));
     }
     else
     {
         opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.Fill__NOFillHITTEST, 0x00010000));
     }
     opt.AddEscherProperty(new EscherRGBProperty(EscherProperties.Fill__FillCOLOR, shape.FillColor));
     opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.GROUPSHAPE__PRINT, 0x080000));
     opt.AddEscherProperty(new EscherRGBProperty(EscherProperties.LINESTYLE__COLOR, shape.LineStyleColor));
     int options = 5;
     if (shape.LineWidth != HSSFShape.LINEWIDTH_DEFAULT)
     {
         opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEWIDTH, shape.LineWidth));
         options++;
     }
     if (shape.LineStyle != HSSFShape.LINESTYLE_SOLID)
     {
         opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEDASHING, shape.LineStyle));
         opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEENDCAPSTYLE, 0));
         if (shape.LineStyle == HSSFShape.LINESTYLE_NONE)
             opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x00080000));
         else
             opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x00080008));
         options += 3;
     }
     opt.SortProperties();
     return options;   // # options Added
 }
예제 #19
0
 /// <summary>
 /// Create a new shape with the specified parent and anchor.
 /// </summary>
 /// <param name="parent">The parent.</param>
 /// <param name="anchor">The anchor.</param>
 public HSSFShape(HSSFShape parent, HSSFAnchor anchor)
 {
     this.parent = parent;
     this.anchor = anchor;
     this._escherContainer = CreateSpContainer();
     _optRecord = (EscherOptRecord)_escherContainer.GetChildById(EscherOptRecord.RECORD_ID);
     _objRecord = CreateObjRecord();
 }
예제 #20
0
 /**
  * Set an escher property for this shape.
  *
  * @param opt       The opt record to Set the properties to.
  * @param propId    The id of the property. One of the constants defined in EscherOptRecord.
  * @param value     value of the property. If value = -1 then the property is Removed.
  */
 public static void SetEscherProperty(EscherOptRecord opt, short propId, int value)
 {
     List<EscherProperty> props = opt.EscherProperties;
     for (List<EscherProperty>.Enumerator iterator = props.GetEnumerator(); iterator.MoveNext(); )
     {
         EscherProperty prop = (EscherProperty)iterator.Current;
         if (prop.Id == propId)
         {
             props.Remove(iterator.Current);
         }
     }
     if (value != -1)
     {
         opt.AddEscherProperty(new EscherSimpleProperty(propId, value));
         opt.SortProperties();
     }
 }
예제 #21
0
 public void TestToString()
 {
     String nl = Environment.NewLine;
     EscherOptRecord r = new EscherOptRecord();
     // don't try to shoot in foot, please -- vlsergey
     // r.setOptions((short)0x000F);
     r.RecordId=EscherOptRecord.RECORD_ID;
     EscherProperty prop1 = new EscherBoolProperty((short)1, 1);
     r.AddEscherProperty(prop1);
     String expected = "EscherOptRecord:" + nl +
             "  isContainer: False" + nl +
             "  version: 0x0003" + nl +
             "  instance: 0x0001" + nl +
             "  recordId: 0x" + HexDump.ToHex(EscherOptRecord.RECORD_ID) + nl +
             "  numchildren: 0" + nl +
             "  properties:" + nl +
             "    propNum: 1, RAW: 0x0001, propName: unknown, complex: False, blipId: False, value: 1 (0x00000001)" + nl;
     Assert.AreEqual(expected, r.ToString());
 }
예제 #22
0
        private void CheckSerializeComplex()
        {
            //Complex escher record
            EscherOptRecord r = new EscherOptRecord();
            r.Options=(short)0x0033;
            r.RecordId=unchecked((short)0xF00B);
            EscherBoolProperty prop1 = new EscherBoolProperty(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 1);
            EscherComplexProperty prop2 = new EscherComplexProperty((short)1, false, new byte[] { 0x01, 0x02 });
            EscherBoolProperty prop3 = new EscherBoolProperty(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 1);
            r.AddEscherProperty(prop1);
            r.AddEscherProperty(prop2);
            r.AddEscherProperty(prop3);

            byte[] data = new byte[28];
            int bytesWritten = r.Serialize(0, data);
            Assert.AreEqual(28, bytesWritten);
            String dataStr = "[33, 00, " +
                    "0B, F0, " +
                    "14, 00, 00, 00, " +
                    "BF, 00, 01, 00, 00, 00, " +
                    "01, 80, 02, 00, 00, 00, " +
                    "BF, 00, 01, 00, 00, 00, " +
                    "01, 02, ]";
            Assert.AreEqual(dataStr, HexDump.ToHex(data));

        }
예제 #23
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
        }
예제 #24
0
        /// <summary>
        /// Sets standard escher options for a comment.
        /// This method is responsible for Setting default background,
        /// shading and other comment properties.
        /// </summary>
        /// <param name="shape">The highlevel shape.</param>
        /// <param name="opt">The escher records holding the proerties</param>
        /// <returns>The number of escher options added</returns>
        protected override int AddStandardOptions(HSSFShape shape, EscherOptRecord opt)
        {
            base.AddStandardOptions(shape, opt);

            //Remove Unnecessary properties inherited from TextboxShape
            IList props = (IList)opt.EscherProperties.Clone();
            for (IEnumerator iterator = props.GetEnumerator(); iterator.MoveNext(); )
            {
                EscherProperty prop = (EscherProperty)iterator.Current;
                switch (prop.Id)
                {
                    case EscherProperties.TEXT__TEXTLEFT:
                    case EscherProperties.TEXT__TEXTRIGHT:
                    case EscherProperties.TEXT__TEXTTOP:
                    case EscherProperties.TEXT__TEXTBOTTOM:
                    case EscherProperties.GROUPSHAPE__PRINT:
                    case EscherProperties.Fill__FillBACKCOLOR:
                    case EscherProperties.LINESTYLE__COLOR:
                        opt.EscherProperties.Remove(prop);
                        break;
                }
            }

            HSSFComment comment = (HSSFComment)shape;
            opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.GROUPSHAPE__PRINT, comment.Visible ? 0x000A0000 : 0x000A0002));
            opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.SHADOWSTYLE__SHADOWOBSURED, 0x00030003));
            opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.SHADOWSTYLE__COLOR, 0x00000000));
            opt.SortProperties();
            return opt.EscherProperties.Count;   // # options Added
        }
예제 #25
0
        /**
         * Creates a primary drawing Group record.  If it already 
         *  exists then it's modified.
         */
        public void CreateDrawingGroup()
        {
            if (drawingManager == null)
            {
                EscherContainerRecord dggContainer = new EscherContainerRecord();
                EscherDggRecord dgg = new EscherDggRecord();
                EscherOptRecord opt = new EscherOptRecord();
                EscherSplitMenuColorsRecord splitMenuColors = new EscherSplitMenuColorsRecord();

                dggContainer.RecordId=unchecked((short)0xF000);
                dggContainer.Options=(short)0x000F;
                dgg.RecordId=EscherDggRecord.RECORD_ID;
                dgg.Options=(short)0x0000;
                dgg.ShapeIdMax=1024;
                dgg.NumShapesSaved=0;
                dgg.DrawingsSaved=0;
                dgg.FileIdClusters=new EscherDggRecord.FileIdCluster[] { };
                drawingManager = new DrawingManager2(dgg);
                EscherContainerRecord bstoreContainer = null;
                if (escherBSERecords.Count > 0)
                {
                    bstoreContainer = new EscherContainerRecord();
                    bstoreContainer.RecordId=EscherContainerRecord.BSTORE_CONTAINER;
                    bstoreContainer.Options=(short)((escherBSERecords.Count << 4) | 0xF);
                    for (IEnumerator iterator = escherBSERecords.GetEnumerator(); iterator.MoveNext(); )
                    {
                        EscherRecord escherRecord = (EscherRecord)iterator.Current;
                        bstoreContainer.AddChildRecord(escherRecord);
                    }
                }
                opt.RecordId=unchecked((short)0xF00B);
                opt.Options=(short)0x0033;
                opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 524296));
                opt.AddEscherProperty(new EscherRGBProperty(EscherProperties.FILL__FILLCOLOR, 0x08000041));
                opt.AddEscherProperty(new EscherRGBProperty(EscherProperties.LINESTYLE__COLOR, 134217792));
                splitMenuColors.RecordId=unchecked((short)0xF11E);
                splitMenuColors.Options=(short)0x0040;
                splitMenuColors.Color1=0x0800000D;
                splitMenuColors.Color2=0x0800000C;
                splitMenuColors.Color3=0x08000017;
                splitMenuColors.Color4=0x100000F7;

                dggContainer.AddChildRecord(dgg);
                if (bstoreContainer != null)
                    dggContainer.AddChildRecord(bstoreContainer);
                dggContainer.AddChildRecord(opt);
                dggContainer.AddChildRecord(splitMenuColors);

                int dgLoc = FindFirstRecordLocBySid(DrawingGroupRecord.sid);
                if (dgLoc == -1)
                {
                    DrawingGroupRecord drawingGroup = new DrawingGroupRecord();
                    drawingGroup.AddEscherRecord(dggContainer);
                    int loc = FindFirstRecordLocBySid(CountryRecord.sid);

                    Records.Insert(loc + 1, drawingGroup);
                }
                else
                {
                    DrawingGroupRecord drawingGroup = new DrawingGroupRecord();
                    drawingGroup.AddEscherRecord(dggContainer);
                    Records[dgLoc]= drawingGroup;
                }

            }
        }
예제 #26
0
        public void TestToString()
        {
            EscherContainerRecord r = new EscherContainerRecord();
            r.RecordId=EscherContainerRecord.SP_CONTAINER;
            r.Options=(short)0x000F;
            String nl = Environment.NewLine;
            Assert.AreEqual("EscherContainerRecord (SpContainer):" + nl +
                    "  isContainer: True" + nl +
                    "  version: 0x000F" + nl +
                    "  instance: 0x0000" + nl +
                    "  recordId: 0xF004" + nl +
                    "  numchildren: 0" + nl
                    , r.ToString());

            EscherOptRecord r2 = new EscherOptRecord();
            // don't try to shoot in foot, please -- vlsergey
            // r2.setOptions((short) 0x9876);
            r2.RecordId=EscherOptRecord.RECORD_ID;

            String expected;
            r.AddChildRecord(r2);
            expected = "EscherContainerRecord (SpContainer):" + nl +
                       "  isContainer: True" + nl +
                       "  version: 0x000F" + nl +
                       "  instance: 0x0000" + nl +
                       "  recordId: 0xF004" + nl +
                       "  numchildren: 1" + nl +
                       "  children: " + nl +
                       "    Child 0:" + nl +
                       "    EscherOptRecord:" + nl +
                       "      isContainer: False" + nl +
                       "      version: 0x0003" + nl +
                       "      instance: 0x0000" + nl +
                       "      recordId: 0xF00B" + nl +
                       "      numchildren: 0" + nl +
                       "      properties:" + nl +
                       "    " + nl;
            Assert.AreEqual(expected, r.ToString());

            r.AddChildRecord(r2);
            expected = "EscherContainerRecord (SpContainer):" + nl +
                       "  isContainer: True" + nl +
                       "  version: 0x000F" + nl +
                       "  instance: 0x0000" + nl +
                       "  recordId: 0xF004" + nl +
                       "  numchildren: 2" + nl +
                       "  children: " + nl +
                       "    Child 0:" + nl +
                       "    EscherOptRecord:" + nl +
                       "      isContainer: False" + nl +
                       "      version: 0x0003" + nl +
                       "      instance: 0x0000" + nl +
                       "      recordId: 0xF00B" + nl +
                       "      numchildren: 0" + nl +
                       "      properties:" + nl +
                       "    " + nl +
                       "    Child 1:" + nl +
                       "    EscherOptRecord:" + nl +
                       "      isContainer: False" + nl +
                       "      version: 0x0003" + nl +
                       "      instance: 0x0000" + nl +
                       "      recordId: 0xF00B" + nl +
                       "      numchildren: 0" + nl +
                       "      properties:" + nl +
                       "    " + nl;
            Assert.AreEqual(expected, r.ToString());
        }
예제 #27
0
 /**
  * Returns  escher property by id.
  *
  * @return escher property or <code>null</code> if not found.
  */
 public static EscherProperty GetEscherProperty(EscherOptRecord opt, int propId)
 {
     if (opt != null)
     {
         for (List<EscherProperty>.Enumerator iterator = opt.EscherProperties.GetEnumerator(); iterator.MoveNext(); )
         {
             EscherProperty prop = (EscherProperty)iterator.Current;
             if (prop.PropertyNumber == propId)
                 return prop;
         }
     }
     return null;
 }
예제 #28
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;
        }
예제 #29
0
파일: PolygonShape.cs 프로젝트: WPG/npoi
        /// <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(HSSFPolygon hssfShape, int shapeId)
        {
            HSSFShape shape = hssfShape;

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

            spContainer.RecordId=EscherContainerRecord.SP_CONTAINER;
            spContainer.Options=(short)0x000F;
            sp.RecordId=EscherSpRecord.RECORD_ID;
            sp.Options = (short)((EscherAggregate.ST_NOT_PRIMATIVE << 4) | 0x2);
            sp.ShapeId=shapeId;
            if (hssfShape.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.AddEscherProperty(new EscherSimpleProperty(EscherProperties.TRANSFORM__ROTATION, false, false, 0));
            opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__RIGHT, false, false, hssfShape.DrawAreaWidth));
            opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__BOTTOM, false, false, hssfShape.DrawAreaHeight));
            opt.AddEscherProperty(new EscherShapePathProperty(EscherProperties.GEOMETRY__SHAPEPATH, EscherShapePathProperty.COMPLEX));
            EscherArrayProperty verticesProp = new EscherArrayProperty(EscherProperties.GEOMETRY__VERTICES, false, new byte[0]);
            verticesProp.NumberOfElementsInArray=(hssfShape.XPoints.Length + 1);
            verticesProp.NumberOfElementsInMemory=(hssfShape.XPoints.Length + 1);
            verticesProp.SizeOfElements=unchecked((short)0xFFF0);
            for (int i = 0; i < hssfShape.XPoints.Length; i++)
            {
                byte[] data = new byte[4];
                LittleEndian.PutShort(data, 0, (short)hssfShape.XPoints[i]);
                LittleEndian.PutShort(data, 2, (short)hssfShape.YPoints[i]);
                verticesProp.SetElement(i, data);
            }
            int point = hssfShape.XPoints.Length;
            byte[] data1 = new byte[4];
            LittleEndian.PutShort(data1, 0, (short)hssfShape.XPoints[0]);
            LittleEndian.PutShort(data1, 2, (short)hssfShape.YPoints[0]);
            verticesProp.SetElement(point, data1);
            opt.AddEscherProperty(verticesProp);
            EscherArrayProperty segmentsProp = new EscherArrayProperty(EscherProperties.GEOMETRY__SEGMENTINFO, false, null);
            segmentsProp.SizeOfElements=(0x0002);
            segmentsProp.NumberOfElementsInArray=(hssfShape.XPoints.Length * 2 + 4);
            segmentsProp.NumberOfElementsInMemory=(hssfShape.XPoints.Length * 2 + 4);
            segmentsProp.SetElement(0, new byte[] { (byte)0x00, (byte)0x40 });
            segmentsProp.SetElement(1, new byte[] { (byte)0x00, (byte)0xAC });
            for (int i = 0; i < hssfShape.XPoints.Length; i++)
            {
                segmentsProp.SetElement(2 + i * 2, new byte[] { (byte)0x01, (byte)0x00 });
                segmentsProp.SetElement(3 + i * 2, new byte[] { (byte)0x00, (byte)0xAC });
            }
            segmentsProp.SetElement(segmentsProp.NumberOfElementsInArray - 2, new byte[] { (byte)0x01, (byte)0x60 });
            segmentsProp.SetElement(segmentsProp.NumberOfElementsInArray - 1, new byte[] { (byte)0x00, (byte)0x80 });
            opt.AddEscherProperty(segmentsProp);
            opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__FILLOK, false, false, 0x00010001));
            opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINESTARTARROWHEAD, false, false, 0x0));
            opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEENDARROWHEAD, false, false, 0x0));
            opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEENDCAPSTYLE, false, false, 0x0));

            AddStandardOptions(shape, opt);

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

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

            return spContainer;
        }
예제 #30
0
        /// <summary>
        /// Sets standard escher options for a comment.
        /// This method is responsible for Setting default background,
        /// shading and other comment properties.
        /// </summary>
        /// <param name="shape">The highlevel shape.</param>
        /// <param name="opt">The escher records holding the proerties</param>
        /// <returns>The number of escher options added</returns>
        protected override int AddStandardOptions(HSSFShape shape, EscherOptRecord opt)
        {
            base.AddStandardOptions(shape, opt);

            //Remove Unnecessary properties inherited from TextboxShape
            for (int i = 0; i < opt.EscherProperties.Count; i++ )
            {
                EscherProperty prop = opt.EscherProperties[i];
                switch (prop.Id)
                {
                    case EscherProperties.TEXT__TEXTLEFT:
                    case EscherProperties.TEXT__TEXTRIGHT:
                    case EscherProperties.TEXT__TEXTTOP:
                    case EscherProperties.TEXT__TEXTBOTTOM:
                    case EscherProperties.GROUPSHAPE__PRINT:
                    case EscherProperties.FILL__FILLBACKCOLOR:
                    case EscherProperties.LINESTYLE__COLOR:
                        opt.EscherProperties.Remove(prop);
                        i--;
                        break;
                }
            }

            HSSFComment comment = (HSSFComment)shape;
            opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.GROUPSHAPE__PRINT, comment.Visible ? 0x000A0000 : 0x000A0002));
            opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.SHADOWSTYLE__SHADOWOBSURED, 0x00030003));
            opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.SHADOWSTYLE__COLOR, 0x00000000));
            opt.SortProperties();
            return opt.EscherProperties.Count;   // # options Added
        }