/// <summary> Constructs a property set /// /// </summary> /// <param name="d">the bytes /// </param> public PropertyStorage(BaseCompoundFile enclosingInstance, sbyte[] d) { InitBlock(enclosingInstance); data = d; int nameSize = IntegerHelper.getInt(data[NExcel.Biff.BaseCompoundFile.SIZE_OF_NAME_POS], data[NExcel.Biff.BaseCompoundFile.SIZE_OF_NAME_POS + 1]); type = data[NExcel.Biff.BaseCompoundFile.TYPE_POS]; startBlock = IntegerHelper.getInt(data[NExcel.Biff.BaseCompoundFile.START_BLOCK_POS], data[NExcel.Biff.BaseCompoundFile.START_BLOCK_POS + 1], data[NExcel.Biff.BaseCompoundFile.START_BLOCK_POS + 2], data[NExcel.Biff.BaseCompoundFile.START_BLOCK_POS + 3]); size = IntegerHelper.getInt(data[NExcel.Biff.BaseCompoundFile.SIZE_POS], data[NExcel.Biff.BaseCompoundFile.SIZE_POS + 1], data[NExcel.Biff.BaseCompoundFile.SIZE_POS + 2], data[NExcel.Biff.BaseCompoundFile.SIZE_POS + 3]); int chars = 0; if (nameSize > 2) { chars = (nameSize - 1) / 2; } System.Text.StringBuilder n = new System.Text.StringBuilder(""); for (int i = 0; i < chars; i++) { n.Append((char)data[i * 2]); } name = n.ToString(); }
/// <summary> Constructs an empty property set. Used when writing the file /// /// </summary> /// <param name="name">the property storage name /// </param> public PropertyStorage(BaseCompoundFile enclosingInstance, string name) { InitBlock(enclosingInstance); data = new sbyte[NExcel.Biff.BaseCompoundFile.PROPERTY_STORAGE_BLOCK_SIZE]; Assert.verify(name.Length < 32); IntegerHelper.getTwoBytes((name.Length + 1) * 2, data, NExcel.Biff.BaseCompoundFile.SIZE_OF_NAME_POS); // add one to the name .Length to allow for the null character at // the end for (int i = 0; i < name.Length; i++) { data[i * 2] = (sbyte)name[i]; } }
private void InitBlock(BaseCompoundFile enclosingInstance) { this.enclosingInstance = enclosingInstance; }