コード例 #1
0
 /// <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);
 }
コード例 #2
0
ファイル: MutablePropertySet.cs プロジェクト: xiepeixing/npoi
 /// <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 List<Section>();
     sections.Add(section);
 }
コード例 #3
0
 /// <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);
 }
コード例 #4
0
ファイル: PropertySet.cs プロジェクト: JnS-Software-LLC/npoi
        /// <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 List<Section>(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);
            }
        }
コード例 #5
0
 /// <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);
 }
コード例 #6
0
        /**
         * Checks whether this section is equal To another object. The result Is
         * <c>false</c> if one of the the following conditions holds:
         *
         * <ul>
         *
         * <li>The other object is not a {@link Section}.</li>
         *
         * <li>The format IDs of the two sections are not equal.</li>
         *
         * <li>The sections have a different number of properties. However,
         * properties with ID 1 (codepage) are not counted.</li>
         *
         * <li>The other object is not a {@link Section}.</li>
         *
         * <li>The properties have different values. The order of the properties
         * is irrelevant.</li>
         *
         * </ul>
         *
         * @param o The object To Compare this section with
         * @return <c>true</c> if the objects are equal, <c>false</c> if
         * not
         */
        public override bool Equals(Object o)
        {
            if (o == null || !(o is Section))
            {
                return(false);
            }
            Section s = (Section)o;

            if (!s.FormatID.Equals(FormatID))
            {
                return(false);
            }

            /* Compare all properties except 0 and 1 as they must be handled
             * specially. */
            Property[] pa1 = new Property[Properties.Length];
            Property[] pa2 = new Property[s.Properties.Length];
            System.Array.Copy(Properties, 0, pa1, 0, pa1.Length);
            System.Array.Copy(s.Properties, 0, pa2, 0, pa2.Length);

            /* Extract properties 0 and 1 and Remove them from the copy of the
             * arrays. */
            Property p10 = null;
            Property p20 = null;

            for (int i = 0; i < pa1.Length; i++)
            {
                long id = pa1[i].ID;
                if (id == 0)
                {
                    p10 = pa1[i];
                    pa1 = Remove(pa1, i);
                    i--;
                }
                if (id == 1)
                {
                    // p11 = pa1[i];
                    pa1 = Remove(pa1, i);
                    i--;
                }
            }
            for (int i = 0; i < pa2.Length; i++)
            {
                long id = pa2[i].ID;
                if (id == 0)
                {
                    p20 = pa2[i];
                    pa2 = Remove(pa2, i);
                    i--;
                }
                if (id == 1)
                {
                    // p21 = pa2[i];
                    pa2 = Remove(pa2, i);
                    i--;
                }
            }

            /* If the number of properties (not counting property 1) is unequal the
             * sections are unequal. */
            if (pa1.Length != pa2.Length)
            {
                return(false);
            }

            /* If the dictionaries are unequal the sections are unequal. */
            bool dictionaryEqual = true;

            if (p10 != null && p20 != null)
            {
                //tony qu fixed this issue
                Hashtable a = (Hashtable)p10.Value;
                Hashtable b = (Hashtable)p20.Value;
                dictionaryEqual = a.Count == b.Count;
            }
            else if (p10 != null || p20 != null)
            {
                dictionaryEqual = false;
            }
            if (!dictionaryEqual)
            {
                return(false);
            }
            else
            {
                return(Util.AreEqual(pa1, pa2));
            }
        }
コード例 #7
0
 /// <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);
 }