Beispiel #1
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);
        }
Beispiel #2
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);
        }
Beispiel #3
0
        private TextObjectRecord GetOrCreateTextObjRecord()
        {
            if (GetTextObjectRecord() == null)
            {
                _textObjectRecord = CreateTextObjRecord();
            }
            EscherTextboxRecord escherTextbox = (EscherTextboxRecord)GetEscherContainer().GetChildById(EscherTextboxRecord.RECORD_ID);

            if (null == escherTextbox)
            {
                escherTextbox          = new EscherTextboxRecord();
                escherTextbox.RecordId = (EscherTextboxRecord.RECORD_ID);
                escherTextbox.Options  = ((short)0x0000);
                GetEscherContainer().AddChildRecord(escherTextbox);
                Patriarch.getBoundAggregate().AssociateShapeToObjRecord(escherTextbox, _textObjectRecord);
            }
            return(_textObjectRecord);
        }
Beispiel #4
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);
        }
        private void ConvertRecordsToUserModel(EscherContainerRecord shapeContainer, Object model)
        {
            for (IEnumerator it = shapeContainer.ChildRecords.GetEnumerator(); it.MoveNext();)
            {
                EscherRecord r = (EscherRecord)it.Current;
                if (r is EscherSpgrRecord)
                {
                    // This may be overriden by a later EscherClientAnchorRecord
                    EscherSpgrRecord spgr = (EscherSpgrRecord)r;

                    if (model is HSSFShapeGroup)
                    {
                        HSSFShapeGroup g = (HSSFShapeGroup)model;
                        g.SetCoordinates(
                            spgr.RectX1, spgr.RectY1,
                            spgr.RectX2, spgr.RectY2
                            );
                    }
                    else
                    {
                        throw new InvalidOperationException("Got top level anchor but not Processing a Group");
                    }
                }
                else if (r is EscherClientAnchorRecord)
                {
                    EscherClientAnchorRecord car = (EscherClientAnchorRecord)r;

                    if (model is HSSFShape)
                    {
                        HSSFShape g = (HSSFShape)model;
                        g.Anchor.Dx1 = car.Dx1;
                        g.Anchor.Dx2 = car.Dx2;
                        g.Anchor.Dy1 = car.Dy1;
                        g.Anchor.Dy2 = car.Dy2;
                    }
                    else
                    {
                        throw new InvalidOperationException("Got top level anchor but not Processing a Group or shape");
                    }
                }
                else if (r is EscherTextboxRecord)
                {
                    EscherTextboxRecord tbr = (EscherTextboxRecord)r;

                    // Also need to Find the TextObjectRecord too
                    // TODO
                }
                else if (r is EscherSpRecord)
                {
                    // Use flags if needed
                }
                else if (r is EscherOptRecord)
                {
                    // Use properties if needed
                }
                else
                {
                    //Console.Error.WriteLine(r);
                }
            }
        }