/// <summary> /// Initializes this {@link PropertySet} instance from a byte /// array. The method assumes that it has been checked alReady that /// the byte array indeed represents a property Set stream. It does /// no more checks on its own. /// </summary> /// <param name="src">Byte array containing the property Set stream</param> /// <param name="offset">The property Set stream starts at this offset</param> /// <param name="Length">Length of the property Set stream.</param> private void init(byte[] src, int offset, int Length) { /* FIXME (3): Ensure that at most "Length" bytes are Read. */ /* * Read the stream's header fields. */ int o = offset; byteOrder = LittleEndian.GetUShort(src, o); o += LittleEndianConsts.SHORT_SIZE; format = LittleEndian.GetUShort(src, o); o += LittleEndianConsts.SHORT_SIZE; osVersion = (int)LittleEndian.GetUInt(src, o); o += LittleEndianConsts.INT_SIZE; classID = new ClassID(src, o); o += ClassID.LENGTH; int sectionCount = LittleEndian.GetInt(src, o); o += LittleEndianConsts.INT_SIZE; if (sectionCount < 0) throw new HPSFRuntimeException("Section count " + sectionCount + " is negative."); /* * Read the sections, which are following the header. They * start with an array of section descriptions. Each one * consists of a format ID telling what the section Contains * and an offset telling how many bytes from the start of the * stream the section begins. */ /* * Most property Sets have only one section. The Document * Summary Information stream has 2. Everything else is a rare * exception and is no longer fostered by Microsoft. */ sections = new ArrayList(sectionCount); /* * Loop over the section descriptor array. Each descriptor * consists of a ClassID and a DWord, and we have To increment * "offset" accordingly. */ for (int i = 0; i < sectionCount; i++) { Section s = new Section(src, o); o += ClassID.Length + LittleEndianConsts.INT_SIZE; sections.Add(s); } }
/// <summary> /// Adds a section To this property set. /// </summary> /// <param name="section">The {@link Section} To Add. It will be Appended /// after any sections that are alReady present in the property Set /// and thus become the last section.</param> public override void AddSection(Section section) { delegate1.AddSection(section); }
/// <summary> /// Adds a section To this property Set. /// </summary> /// <param name="section">section The {@link Section} To Add. It will be Appended /// after any sections that are alReady present in the property Set /// and thus become the last section.</param> public virtual void AddSection(Section section) { if (sections == null) sections = new ArrayList(); sections.Add(section); }
/// <summary> /// Constructs a <c>MutableSection</c> by doing a deep copy of an /// existing <c>Section</c>. All nested <c>Property</c> /// instances, will be their mutable counterparts in the new /// <c>MutableSection</c>. /// </summary> /// <param name="s">The section Set To copy</param> public MutableSection(Section s) { SetFormatID(s.FormatID); Property[] pa = s.Properties; MutableProperty[] mpa = new MutableProperty[pa.Length]; for (int i = 0; i < pa.Length; i++) mpa[i] = new MutableProperty(pa[i]); SetProperties(mpa); this.Dictionary=(s.Dictionary); }