/// <summary>
        /// Creates the anchor.
        /// </summary>
        /// <param name="userAnchor">The user anchor.</param>
        /// <returns></returns>
        public static EscherRecord CreateAnchor(HSSFAnchor userAnchor)
        {
            if (userAnchor is HSSFClientAnchor)
            {
                HSSFClientAnchor a = (HSSFClientAnchor)userAnchor;

                EscherClientAnchorRecord anchor = new EscherClientAnchorRecord();
                anchor.RecordId=EscherClientAnchorRecord.RECORD_ID;
                anchor.Options=(short)0x0000;
                anchor.Flag=(short)a.AnchorType;
                anchor.Col1=(short)Math.Min(a.Col1, a.Col2);
                anchor.Dx1=(short)a.Dx1;
                anchor.Row1=(short)Math.Min(a.Row1, a.Row2);
                anchor.Dy1=(short)a.Dy1;

                anchor.Col2=(short)Math.Max(a.Col1, a.Col2);
                anchor.Dx2=(short)a.Dx2;
                anchor.Row2=(short)Math.Max(a.Row1, a.Row2);
                anchor.Dy2=(short)a.Dy2;
                return anchor;
            }
            else
            {
                HSSFChildAnchor a = (HSSFChildAnchor)userAnchor;
                EscherChildAnchorRecord anchor = new EscherChildAnchorRecord();
                anchor.RecordId=EscherChildAnchorRecord.RECORD_ID;
                anchor.Options=(short)0x0000;
                anchor.Dx1=(short)Math.Min(a.Dx1, a.Dx2);
                anchor.Dy1=(short)Math.Min(a.Dy1, a.Dy2);
                anchor.Dx2=(short)Math.Max(a.Dx2, a.Dx1);
                anchor.Dy2=(short)Math.Max(a.Dy2, a.Dy1);
                return anchor;
            }
        }
Example #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();
            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 #3
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;
        }