zhao
2021-06-24 02ca96debc6056275d58e55d97f7885a195542d0
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
using System;
using System.Collections.Generic;
using System.IO;
 
namespace HH.WMS.Utils.ExcelLibrary.BinaryDrawingFormat
{
    /// <summary>
    /// Shape Properties msofbtOPT
    /// The first part of an OPT record is an array of FOPTEs,
    /// consisting of ID-value pairs 
    /// </summary>
    public class ShapeProperty
    {
        public PropertyIDs PropertyID;
 
        /// <summary>
        /// BLIP properties just store a BLIP ID (basically an index into an array in the BLIP Store).
        /// only valid if IsComplex is false
        /// </summary>
        public bool IsBlipID;
 
        /// <summary>
        /// if true, PropertyValue is the length of the data.
        /// The data of the complex properties follows the FOPTE array in the file record.
        /// </summary>
        public bool IsComplex;
 
        public UInt32 PropertyValue;
 
        public byte[] ComplexData;
 
        public const int Size = 6;
 
        public static ShapeProperty Decode(BinaryReader reader)
        {
            ShapeProperty property = new ShapeProperty();
            UInt16 num = reader.ReadUInt16();
            property.PropertyID = (PropertyIDs)(num & 0x3FFF);
            property.IsBlipID = (num & 0x4000) == 0x4000;
            property.IsComplex = (num & 0x8000) == 0x8000;
            property.PropertyValue = reader.ReadUInt32();
            return property;
        }
 
        public void Encode(BinaryWriter writer)
        {
            UInt16 num = (UInt16)((UInt16)PropertyID & 0x3FFF);
            if (IsBlipID)
            {
                num = (UInt16)(num | 0x4000);
            }
            if (IsComplex)
            {
                num = (UInt16)(num | 0x8000);
            }
            writer.Write(num);
            writer.Write(PropertyValue);
        }
    }
 
}