zhao
2021-07-02 23ee356c6f260ecc1a48bbb8bd60932b979e4698
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
namespace HH.WMS.Utils.NPOI.HSSF.Model
{
    using System;
    using System.Collections;
    using HH.WMS.Utils.NPOI.DDF;
    using HH.WMS.Utils.NPOI.HSSF.UserModel;
    using HH.WMS.Utils.NPOI.HSSF.Record;
 
 
    public class ComboboxShape:AbstractShape
    {
        private EscherContainerRecord spContainer;
        private ObjRecord objRecord;
 
        /**
         * Creates the low evel records for a combobox.
         *
         * @param hssfShape The highlevel shape.
         * @param shapeId   The shape id to use for this shape.
         */
        public ComboboxShape(HSSFSimpleShape hssfShape, int shapeId)
        {
            spContainer = CreateSpContainer(hssfShape, shapeId);
            objRecord = CreateObjRecord(hssfShape, shapeId);
        }
 
        /**
         * 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 = 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;
        }
 
        public override EscherContainerRecord SpContainer
        {
            get
            {
                return spContainer;
            }
        }
 
        public override ObjRecord ObjRecord
        {
            get
            {
                return objRecord;
            }
        }
    }
}