Example #1
0
        /// <summary>
        /// This method Serializes this escher record into a byte array.
        /// @param offset
        /// </summary>
        /// <param name="offset">The offset into data to start writing the record data to.</param>
        /// <param name="data">the data array to Serialize to</param>
        /// <param name="listener">a listener for begin and end serialization events.</param>
        /// <returns>the number of bytes written.</returns>
        public override int Serialize(int offset, byte[] data, EscherSerializationListener listener)
        {
            listener.BeforeRecordSerialize(offset, RecordId, this);

            LittleEndian.PutShort(data, offset, Options);
            LittleEndian.PutShort(data, offset + 2, RecordId);
            int remainingBytes = field_12_data.Length + 36;

            LittleEndian.PutInt(data, offset + 4, remainingBytes);

            int pos = offset + HEADER_SIZE;

            Array.Copy(field_1_secondaryUID, 0, data, pos, 16); pos       += 16;
            LittleEndian.PutInt(data, pos, field_2_cacheOfSize); pos      += 4;
            LittleEndian.PutInt(data, pos, field_3_boundaryTop); pos      += 4;
            LittleEndian.PutInt(data, pos, field_4_boundaryLeft); pos     += 4;
            LittleEndian.PutInt(data, pos, field_5_boundaryWidth); pos    += 4;
            LittleEndian.PutInt(data, pos, field_6_boundaryHeight); pos   += 4;
            LittleEndian.PutInt(data, pos, field_7_width); pos            += 4;
            LittleEndian.PutInt(data, pos, field_8_height); pos           += 4;
            LittleEndian.PutInt(data, pos, field_9_cacheOfSavedSize); pos += 4;
            data[pos++] = field_10_compressionFlag;
            data[pos++] = field_11_filter;
            Array.Copy(field_12_data, 0, data, pos, field_12_data.Length); pos += field_12_data.Length;

            listener.AfterRecordSerialize(pos, RecordId, pos - offset, this);
            return(pos - offset);
        }
Example #2
0
        /// <summary>
        /// Serializes the record to an existing byte array.
        /// </summary>
        /// <param name="offset">the offset within the byte array</param>
        /// <param name="data">the data array to Serialize to</param>
        /// <param name="listener">a listener for begin and end serialization events.</param>
        /// <returns>the number of bytes written.</returns>
        public override int Serialize(int offset, byte[] data, EscherSerializationListener listener)
        {
            listener.BeforeRecordSerialize(offset, RecordId, this);

            int pos = offset;

            LittleEndian.PutShort(data, pos, Options); pos              += 2;
            LittleEndian.PutShort(data, pos, RecordId); pos             += 2;
            LittleEndian.PutInt(data, 0, RecordSize - HEADER_SIZE); pos += 4;

            Array.Copy(field_1_UID, 0, data, pos, 16); pos           += 16;
            LittleEndian.PutInt(data, pos, field_2_cb); pos          += 4;
            LittleEndian.PutInt(data, pos, field_3_rcBounds_x1); pos += 4;
            LittleEndian.PutInt(data, pos, field_3_rcBounds_y1); pos += 4;
            LittleEndian.PutInt(data, pos, field_3_rcBounds_x2); pos += 4;
            LittleEndian.PutInt(data, pos, field_3_rcBounds_y2); pos += 4;
            LittleEndian.PutInt(data, pos, field_4_ptSize_w); pos    += 4;
            LittleEndian.PutInt(data, pos, field_4_ptSize_h); pos    += 4;
            LittleEndian.PutInt(data, pos, field_5_cbSave); pos      += 4;
            data[pos] = field_6_fCompression; pos++;
            data[pos] = field_7_fFilter; pos++;

            Array.Copy(raw_pictureData, 0, data, pos, raw_pictureData.Length);

            listener.AfterRecordSerialize(offset + RecordSize, RecordId, RecordSize, this);
            return(HEADER_SIZE + 16 + 1 + raw_pictureData.Length);
        }
        /// <summary>
        /// This method Serializes this escher record into a byte array.
        /// </summary>
        /// <param name="offset">The offset into data to start writing the record data to.</param>
        /// <param name="data">The byte array to Serialize to.</param>
        /// <param name="listener">a listener for begin and end serialization events.</param>
        /// <returns>The number of bytes written.</returns>
        public override int Serialize(int offset, byte[] data, EscherSerializationListener listener)
        {
            listener.BeforeRecordSerialize(offset, RecordId, this);

            if (remainingData == null)
            {
                remainingData = new byte[0];
            }
            LittleEndian.PutShort(data, offset, Options);
            LittleEndian.PutShort(data, offset + 2, RecordId);
            int remainingBytes = remainingData.Length + (shortRecord ? 8 : 18);

            LittleEndian.PutInt(data, offset + 4, remainingBytes);
            LittleEndian.PutShort(data, offset + 8, field_1_flag);
            LittleEndian.PutShort(data, offset + 10, field_2_col1);
            LittleEndian.PutShort(data, offset + 12, field_3_dx1);
            LittleEndian.PutShort(data, offset + 14, field_4_row1);
            if (!shortRecord)
            {
                LittleEndian.PutShort(data, offset + 16, field_5_dy1);
                LittleEndian.PutShort(data, offset + 18, field_6_col2);
                LittleEndian.PutShort(data, offset + 20, field_7_dx2);
                LittleEndian.PutShort(data, offset + 22, field_8_row2);
                LittleEndian.PutShort(data, offset + 24, field_9_dy2);
            }
            Array.Copy(remainingData, 0, data, offset + (shortRecord ? 16 : 26), remainingData.Length);
            int pos = offset + 8 + (shortRecord ? 8 : 18) + remainingData.Length;

            listener.AfterRecordSerialize(pos, RecordId, pos - offset, this);
            return(pos - offset);
        }
Example #4
0
        /// <summary>
        /// This method Serializes this escher record into a byte array.
        /// </summary>
        /// <param name="offset">The offset into data to start writing the record data to.</param>
        /// <param name="data">The byte array to Serialize to.</param>
        /// <param name="listener">a listener for begin and end serialization events.</param>
        /// <returns>The number of bytes written.</returns>
        public override int Serialize(int offset, byte[] data, EscherSerializationListener listener)
        {
            listener.BeforeRecordSerialize(offset, RecordId, this);

            int pos = offset;

            LittleEndian.PutShort(data, pos, Options); pos  += 2;
            LittleEndian.PutShort(data, pos, RecordId); pos += 2;
            int remainingBytes = RecordSize - 8;

            LittleEndian.PutInt(data, pos, remainingBytes); pos += 4;

            LittleEndian.PutInt(data, pos, field_1_shapeIdMax); pos     += 4;
            LittleEndian.PutInt(data, pos, NumIdClusters); pos          += 4;
            LittleEndian.PutInt(data, pos, field_3_numShapesSaved); pos += 4;
            LittleEndian.PutInt(data, pos, field_4_drawingsSaved); pos  += 4;
            for (int i = 0; i < field_5_fileIdClusters.Length; i++)
            {
                LittleEndian.PutInt(data, pos, field_5_fileIdClusters[i].DrawingGroupId); pos  += 4;
                LittleEndian.PutInt(data, pos, field_5_fileIdClusters[i].NumShapeIdsUsed); pos += 4;
            }

            listener.AfterRecordSerialize(pos, RecordId, RecordSize, this);
            return(RecordSize);
        }
Example #5
0
        /// <summary>
        /// Serializes to an existing byte array without serialization listener.
        /// This is done by delegating to Serialize(int, byte[], EscherSerializationListener).
        /// </summary>
        /// <param name="offset">the offset within the data byte array.</param>
        /// <param name="data"> the data array to Serialize to.</param>
        /// <param name="listener">a listener for begin and end serialization events.</param>
        /// <returns>The number of bytes written.</returns>
        public override int Serialize(int offset, byte[] data, EscherSerializationListener listener)
        {
            listener.BeforeRecordSerialize(offset, RecordId, this);

            LittleEndian.PutShort(data, offset, Options);
            LittleEndian.PutShort(data, offset + 2, RecordId);
            int remainingBytes = 0;

            for (IEnumerator iterator = ChildRecords.GetEnumerator(); iterator.MoveNext();)
            {
                EscherRecord r = (EscherRecord)iterator.Current;
                remainingBytes += r.RecordSize;
            }

            remainingBytes += _remainingLength;

            LittleEndian.PutInt(data, offset + 4, remainingBytes);
            int pos = offset + 8;

            for (IEnumerator iterator = ChildRecords.GetEnumerator(); iterator.MoveNext();)
            {
                EscherRecord r = (EscherRecord)iterator.Current;
                pos += r.Serialize(pos, data, listener);
            }

            listener.AfterRecordSerialize(pos, RecordId, pos - offset, this);
            return(pos - offset);
        }
        /// <summary>
        /// Serializes the record to an existing byte array.
        /// </summary>
        /// <param name="offset"> the offset within the byte array</param>
        /// <param name="data">the data array to Serialize to</param>
        /// <param name="listener">a listener for begin and end serialization events.</param>
        /// <returns>the number of bytes written.</returns>
        public override int Serialize(int offset, byte[] data, EscherSerializationListener listener)
        {
            listener.BeforeRecordSerialize(offset, RecordId, this);

            LittleEndian.PutShort(data, offset, Options);
            LittleEndian.PutShort(data, offset + 2, RecordId);

            Array.Copy(field_pictureData, 0, data, offset + 4, field_pictureData.Length);

            listener.AfterRecordSerialize(offset + 4 + field_pictureData.Length, RecordId, field_pictureData.Length + 4, this);
            return field_pictureData.Length + 4;
        }
Example #7
0
        /// <summary>
        /// Serializes the record to an existing byte array.
        /// </summary>
        /// <param name="offset"> the offset within the byte array</param>
        /// <param name="data">the data array to Serialize to</param>
        /// <param name="listener">a listener for begin and end serialization events.</param>
        /// <returns>the number of bytes written.</returns>
        public override int Serialize(int offset, byte[] data, EscherSerializationListener listener)
        {
            listener.BeforeRecordSerialize(offset, RecordId, this);

            LittleEndian.PutShort(data, offset, Options);
            LittleEndian.PutShort(data, offset + 2, RecordId);

            Array.Copy(field_pictureData, 0, data, offset + 4, field_pictureData.Length);

            listener.AfterRecordSerialize(offset + 4 + field_pictureData.Length, RecordId, field_pictureData.Length + 4, this);
            return(field_pictureData.Length + 4);
        }
Example #8
0
        /// <summary>
        /// Serializes to an existing byte array without serialization listener.
        /// This is done by delegating to Serialize(int, byte[], EscherSerializationListener).
        /// </summary>
        /// <param name="offset">the offset within the data byte array.</param>
        /// <param name="data"> the data array to Serialize to.</param>
        /// <param name="listener">a listener for begin and end serialization events.</param>
        /// <returns>The number of bytes written.</returns>
        public override int Serialize(int offset, byte[] data, EscherSerializationListener listener)
        {
            listener.BeforeRecordSerialize(offset, RecordId, this);
            
            LittleEndian.PutShort(data, offset, Options);
            LittleEndian.PutShort(data, offset + 2, RecordId);
            int remainingBytes = 8;
            LittleEndian.PutInt(data, offset + 4, remainingBytes);
            LittleEndian.PutInt(data, offset + 8, field_1_shapeId);
            LittleEndian.PutInt(data, offset + 12, field_2_flags);

            listener.AfterRecordSerialize(offset + RecordSize, RecordId, RecordSize, this);
            return 8 + 8;
        }
        /**
         * This method Serializes this escher record into a byte array.
         *
         * @param offset   The offset into <c>data</c> to start writing the record data to.
         * @param data     The byte array to Serialize to.
         * @param listener A listener to retrieve start and end callbacks.  Use a <c>NullEscherSerailizationListener</c> to ignore these events.
         * @return The number of bytes written.
         * @see NullEscherSerializationListener
         */
        public override int Serialize(int offset, byte[] data, EscherSerializationListener listener)
        {
            listener.BeforeRecordSerialize(offset, RecordId, this);

            if (remainingData == null) remainingData = new byte[0];
            LittleEndian.PutShort(data, offset, Options);
            LittleEndian.PutShort(data, offset + 2, RecordId);
            LittleEndian.PutInt(data, offset + 4, remainingData.Length);
            Array.Copy(remainingData, 0, data, offset + 8, remainingData.Length);
            int pos = offset + 8 + remainingData.Length;

            listener.AfterRecordSerialize(pos, RecordId, pos - offset, this);
            return pos - offset;
        }
Example #10
0
        /// <summary>
        /// This method Serializes this escher record into a byte array.
        /// </summary>
        /// <param name="offset">The offset into
        /// data to start writing the record data to</param>
        /// <param name="data">The byte array to Serialize to.</param>
        /// <param name="listener">a listener for begin and end serialization events.</param>
        /// <returns>The number of bytes written.</returns>
        public override int Serialize(int offset, byte[] data, EscherSerializationListener listener)
        {
            listener.BeforeRecordSerialize(offset, RecordId, this);

            if (_remainingData == null)
            {
                _remainingData = new byte[0];
            }

            LittleEndian.PutShort(data, offset, Options);
            LittleEndian.PutShort(data, offset + 2, RecordId);
            if (_remainingData == null)
            {
                _remainingData = new byte[0];
            }
            int blipSize       = field_12_blipRecord == null ? 0 : field_12_blipRecord.RecordSize;
            int remainingBytes = _remainingData.Length + 36 + blipSize;

            LittleEndian.PutInt(data, offset + 4, remainingBytes);

            data[offset + 8] = field_1_blipTypeWin32;
            data[offset + 9] = field_2_blipTypeMacOS;
            for (int i = 0; i < 16; i++)
            {
                data[offset + 10 + i] = field_3_uid[i];
            }
            LittleEndian.PutShort(data, offset + 26, field_4_tag);
            LittleEndian.PutInt(data, offset + 28, field_5_size);
            LittleEndian.PutInt(data, offset + 32, field_6_ref);
            LittleEndian.PutInt(data, offset + 36, field_7_offset);
            data[offset + 40] = field_8_usage;
            data[offset + 41] = field_9_name;
            data[offset + 42] = field_10_unused2;
            data[offset + 43] = field_11_unused3;
            int bytesWritten = 0;

            if (field_12_blipRecord != null)
            {
                bytesWritten = field_12_blipRecord.Serialize(offset + 44, data);
            }
            if (_remainingData == null)
            {
                _remainingData = new byte[0];
            }
            Array.Copy(_remainingData, 0, data, offset + 44 + bytesWritten, _remainingData.Length);
            int pos = offset + 8 + 36 + _remainingData.Length + bytesWritten;

            listener.AfterRecordSerialize(pos, RecordId, pos - offset, this);
            return(pos - offset);
        }
        /// <summary>
        /// This method Serializes this escher record into a byte array.
        /// </summary>
        /// <param name="offset"> The offset into data to start writing the record data to.</param>
        /// <param name="data"> The byte array to Serialize to.</param>
        /// <returns>The number of bytes written.</returns>
        public override int Serialize(int offset, byte[] data, EscherSerializationListener listener)
        {
            listener.BeforeRecordSerialize(offset, RecordId, this);

            LittleEndian.PutShort(data, offset, Options);
            LittleEndian.PutShort(data, offset + 2, RecordId);
            LittleEndian.PutInt(data, offset + 4, 8);
            LittleEndian.PutInt(data, offset + 8, field_1_numShapes);
            LittleEndian.PutInt(data, offset + 12, field_2_lastMSOSPID);
            //        Array.Copy( remainingData, 0, data, offset + 26, remainingData.Length );
            //        int pos = offset + 8 + 18 + remainingData.Length;

            listener.AfterRecordSerialize(offset + 16, RecordId, RecordSize, this);
            return RecordSize;
        }
Example #12
0
        /// <summary>
        /// Serializes to an existing byte array without serialization listener.
        /// This is done by delegating to Serialize(int, byte[], EscherSerializationListener).
        /// </summary>
        /// <param name="offset">the offset within the data byte array.</param>
        /// <param name="data"> the data array to Serialize to.</param>
        /// <param name="listener">a listener for begin and end serialization events.</param>
        /// <returns>The number of bytes written.</returns>
        public override int Serialize(int offset, byte[] data, EscherSerializationListener listener)
        {
            listener.BeforeRecordSerialize(offset, RecordId, this);

            LittleEndian.PutShort(data, offset, Options);
            LittleEndian.PutShort(data, offset + 2, RecordId);
            int remainingBytes = 8;

            LittleEndian.PutInt(data, offset + 4, remainingBytes);
            LittleEndian.PutInt(data, offset + 8, field_1_shapeId);
            LittleEndian.PutInt(data, offset + 12, field_2_flags);

            listener.AfterRecordSerialize(offset + RecordSize, RecordId, RecordSize, this);
            return(8 + 8);
        }
        /// <summary>
        /// This method Serializes this escher record into a byte array.
        /// </summary>
        /// <param name="offset">The offset into data to start writing the record data to.</param>
        /// <param name="data">The byte array to Serialize to.</param>
        /// <param name="listener">a listener for begin and end serialization events.</param>
        /// <returns>The number of bytes written.</returns>
        public override int Serialize(int offset, byte[] data, EscherSerializationListener listener)
        {
            listener.BeforeRecordSerialize(offset, RecordId, this);
            int pos = offset;
            LittleEndian.PutShort(data, pos, Options); pos += 2;
            LittleEndian.PutShort(data, pos, RecordId); pos += 2;
            LittleEndian.PutInt(data, pos, RecordSize - 8); pos += 4;
            LittleEndian.PutInt(data, pos, field_1_dx1); pos += 4;
            LittleEndian.PutInt(data, pos, field_2_dy1); pos += 4;
            LittleEndian.PutInt(data, pos, field_3_dx2); pos += 4;
            LittleEndian.PutInt(data, pos, field_4_dy2); pos += 4;

            listener.AfterRecordSerialize(pos, RecordId, pos - offset, this);
            return pos - offset;
        }
Example #14
0
        /// <summary>
        /// This method Serializes this escher record into a byte array.
        /// </summary>
        /// <param name="offset"> The offset into data to start writing the record data to.</param>
        /// <param name="data"> The byte array to Serialize to.</param>
        /// <returns>The number of bytes written.</returns>
        /// <param name="listener">a listener for begin and end serialization events.</param>
        public override int Serialize(int offset, byte[] data, EscherSerializationListener listener)
        {
            listener.BeforeRecordSerialize(offset, RecordId, this);

            LittleEndian.PutShort(data, offset, Options);
            LittleEndian.PutShort(data, offset + 2, RecordId);
            LittleEndian.PutInt(data, offset + 4, 8);
            LittleEndian.PutInt(data, offset + 8, field_1_numShapes);
            LittleEndian.PutInt(data, offset + 12, field_2_lastMSOSPID);
            //        Array.Copy( remainingData, 0, data, offset + 26, remainingData.Length );
            //        int pos = offset + 8 + 18 + remainingData.Length;

            listener.AfterRecordSerialize(offset + 16, RecordId, RecordSize, this);
            return(RecordSize);
        }
Example #15
0
 /// <summary>
 /// This method Serializes this escher record into a byte array
 /// </summary>
 /// <param name="offset">The offset into data
 ///  to start writing the record data to.</param>
 /// <param name="data">The byte array to Serialize to.</param>
 /// <param name="listener">a listener for begin and end serialization events.</param>
 /// <returns>The number of bytes written.</returns>
 public override int Serialize(int offset, byte[] data, EscherSerializationListener listener)
 {
     listener.BeforeRecordSerialize(offset, RecordId, this);
     LittleEndian.PutShort(data, offset, Options);
     LittleEndian.PutShort(data, offset + 2, RecordId);
     int remainingBytes = 16;
     LittleEndian.PutInt(data, offset + 4, remainingBytes);
     LittleEndian.PutInt(data, offset + 8, field_1_rectX1);
     LittleEndian.PutInt(data, offset + 12, field_2_rectY1);
     LittleEndian.PutInt(data, offset + 16, field_3_rectX2);
     LittleEndian.PutInt(data, offset + 20, field_4_rectY2);
     //        Array.Copy( remainingData, 0, data, offset + 26, remainingData.Length );
     //        int pos = offset + 8 + 18 + remainingData.Length;
     listener.AfterRecordSerialize(offset + RecordSize, RecordId, offset + RecordSize, this);
     return 8 + 16;
 }
        /// <summary>
        /// This method Serializes this escher record into a byte array.
        /// </summary>
        /// <param name="offset">The offset into data to start writing the record data to.</param>
        /// <param name="data">The byte array to Serialize to.</param>
        /// <param name="listener">a listener for begin and end serialization events.</param>
        /// <returns>The number of bytes written.</returns>
        public override int Serialize(int offset, byte[] data, EscherSerializationListener listener)
        {
            listener.BeforeRecordSerialize(offset, RecordId, this);
            int pos = offset;

            LittleEndian.PutShort(data, pos, Options); pos      += 2;
            LittleEndian.PutShort(data, pos, RecordId); pos     += 2;
            LittleEndian.PutInt(data, pos, RecordSize - 8); pos += 4;
            LittleEndian.PutInt(data, pos, field_1_dx1); pos    += 4;
            LittleEndian.PutInt(data, pos, field_2_dy1); pos    += 4;
            LittleEndian.PutInt(data, pos, field_3_dx2); pos    += 4;
            LittleEndian.PutInt(data, pos, field_4_dy2); pos    += 4;

            listener.AfterRecordSerialize(pos, RecordId, pos - offset, this);
            return(pos - offset);
        }
        /// <summary>
        /// Serializes the record to an existing byte array.
        /// </summary>
        /// <param name="offset">the offset within the byte array</param>
        /// <param name="data">the data array to Serialize to</param>
        /// <returns>the number of bytes written.</returns>
        public override int Serialize(int offset, byte[] data, EscherSerializationListener listener)
        {
            listener.BeforeRecordSerialize(offset, RecordId, this);

            LittleEndian.PutShort(data, offset, Options);
            LittleEndian.PutShort(data, offset + 2, RecordId);
            LittleEndian.PutInt(data, offset + 4, RecordSize - HEADER_SIZE);
            int pos = offset + HEADER_SIZE;

            Array.Copy(field_1_UID, 0, data, pos, 16);
            data[pos + 16] = field_2_marker;
            Array.Copy(field_pictureData, 0, data, pos + 17, field_pictureData.Length);

            listener.AfterRecordSerialize(offset + RecordSize, RecordId, RecordSize, this);
            return HEADER_SIZE + 16 + 1 + field_pictureData.Length;
        }
Example #18
0
        /// <summary>
        /// Serializes the record to an existing byte array.
        /// </summary>
        /// <param name="offset">the offset within the byte array</param>
        /// <param name="data">the data array to Serialize to</param>
        /// <param name="listener">a listener for begin and end serialization events.</param>
        /// <returns>the number of bytes written.</returns>
        public override int Serialize(int offset, byte[] data, EscherSerializationListener listener)
        {
            listener.BeforeRecordSerialize(offset, RecordId, this);

            LittleEndian.PutShort(data, offset, Options);
            LittleEndian.PutShort(data, offset + 2, RecordId);
            LittleEndian.PutInt(data, offset + 4, RecordSize - HEADER_SIZE);
            int pos = offset + HEADER_SIZE;

            Array.Copy(field_1_UID, 0, data, pos, 16);
            data[pos + 16] = field_2_marker;
            Array.Copy(field_pictureData, 0, data, pos + 17, field_pictureData.Length);

            listener.AfterRecordSerialize(offset + RecordSize, RecordId, RecordSize, this);
            return(HEADER_SIZE + 16 + 1 + field_pictureData.Length);
        }
Example #19
0
        /**
         * This method Serializes this escher record into a byte array.
         *
         * @param offset   The offset into <c>data</c> to start writing the record data to.
         * @param data     The byte array to Serialize to.
         * @param listener A listener to retrieve start and end callbacks.  Use a <c>NullEscherSerailizationListener</c> to ignore these events.
         * @return The number of bytes written.
         * @see NullEscherSerializationListener
         */
        public override int Serialize(int offset, byte[] data, EscherSerializationListener listener)
        {
            listener.BeforeRecordSerialize(offset, RecordId, this);

            if (remainingData == null)
            {
                remainingData = new byte[0];
            }
            LittleEndian.PutShort(data, offset, Options);
            LittleEndian.PutShort(data, offset + 2, RecordId);
            LittleEndian.PutInt(data, offset + 4, remainingData.Length);
            Array.Copy(remainingData, 0, data, offset + 8, remainingData.Length);
            int pos = offset + 8 + remainingData.Length;

            listener.AfterRecordSerialize(pos, RecordId, pos - offset, this);
            return(pos - offset);
        }
        /// <summary>
        /// Writes this record and any contained records to the supplied byte
        /// </summary>
        /// <param name="offset"></param>
        /// <param name="data"></param>
        /// <param name="listener">a listener for begin and end serialization events.</param>
        /// <returns>the number of bytes written.</returns>
        public override int Serialize(int offset, byte[] data, EscherSerializationListener listener)
        {
            listener.BeforeRecordSerialize(offset, RecordId, this);

            LittleEndian.PutShort(data, offset, Options);
            LittleEndian.PutShort(data, offset + 2, RecordId);
            int remainingBytes = thedata.Length;
            LittleEndian.PutInt(data, offset + 4, remainingBytes);
            Array.Copy(thedata, 0, data, offset + 8, thedata.Length);
            int pos = offset + 8 + thedata.Length;

            listener.AfterRecordSerialize(pos, RecordId, pos - offset, this);
            int size = pos - offset;
            if (size != RecordSize)
                throw new RecordFormatException(size + " bytes written but RecordSize reports " + RecordSize);
            return size;
        }
Example #21
0
        /// <summary>
        /// This method Serializes this escher record into a byte array
        /// </summary>
        /// <param name="offset">The offset into data
        ///  to start writing the record data to.</param>
        /// <param name="data">The byte array to Serialize to.</param>
        /// <param name="listener">a listener for begin and end serialization events.</param>
        /// <returns>The number of bytes written.</returns>
        public override int Serialize(int offset, byte[] data, EscherSerializationListener listener)
        {
            listener.BeforeRecordSerialize(offset, RecordId, this);
            LittleEndian.PutShort(data, offset, Options);
            LittleEndian.PutShort(data, offset + 2, RecordId);
            int remainingBytes = 16;

            LittleEndian.PutInt(data, offset + 4, remainingBytes);
            LittleEndian.PutInt(data, offset + 8, field_1_rectX1);
            LittleEndian.PutInt(data, offset + 12, field_2_rectY1);
            LittleEndian.PutInt(data, offset + 16, field_3_rectX2);
            LittleEndian.PutInt(data, offset + 20, field_4_rectY2);
            //        Array.Copy( remainingData, 0, data, offset + 26, remainingData.Length );
            //        int pos = offset + 8 + 18 + remainingData.Length;
            listener.AfterRecordSerialize(offset + RecordSize, RecordId, offset + RecordSize, this);
            return(8 + 16);
        }
        /// <summary>
        /// This method Serializes this escher record into a byte array
        /// </summary>
        /// <param name="offset">The offset into data
        ///  to start writing the record data to.</param>
        /// <param name="data">The byte array to Serialize to.</param>
        /// <param name="listener">a listener for begin and end serialization events.</param>
        /// <returns>The number of bytes written.</returns>
        public override int Serialize(int offset, byte[] data, EscherSerializationListener listener)
        {
            //        int field_2_numIdClusters = field_5_fileIdClusters.Length + 1;
            listener.BeforeRecordSerialize(offset, RecordId, this);

            int pos = offset;
            LittleEndian.PutShort(data, pos, Options); pos += 2;
            LittleEndian.PutShort(data, pos, RecordId); pos += 2;
            int remainingBytes = RecordSize - 8;

            LittleEndian.PutInt(data, pos, remainingBytes); pos += 4;
            LittleEndian.PutInt(data, pos, field_1_color1); pos += 4;
            LittleEndian.PutInt(data, pos, field_2_color2); pos += 4;
            LittleEndian.PutInt(data, pos, field_3_color3); pos += 4;
            LittleEndian.PutInt(data, pos, field_4_color4); pos += 4;
            
            listener.AfterRecordSerialize(pos, RecordId, pos - offset, this);
            return RecordSize;
        }
Example #23
0
        /// <summary>
        /// This method Serializes this escher record into a byte array
        /// </summary>
        /// <param name="offset">The offset into data
        ///  to start writing the record data to.</param>
        /// <param name="data">The byte array to Serialize to.</param>
        /// <param name="listener">a listener for begin and end serialization events.</param>
        /// <returns>The number of bytes written.</returns>
        public override int Serialize(int offset, byte[] data, EscherSerializationListener listener)
        {
            //        int field_2_numIdClusters = field_5_fileIdClusters.Length + 1;
            listener.BeforeRecordSerialize(offset, RecordId, this);

            int pos = offset;

            LittleEndian.PutShort(data, pos, Options); pos  += 2;
            LittleEndian.PutShort(data, pos, RecordId); pos += 2;
            int remainingBytes = RecordSize - 8;

            LittleEndian.PutInt(data, pos, remainingBytes); pos += 4;
            LittleEndian.PutInt(data, pos, field_1_color1); pos += 4;
            LittleEndian.PutInt(data, pos, field_2_color2); pos += 4;
            LittleEndian.PutInt(data, pos, field_3_color3); pos += 4;
            LittleEndian.PutInt(data, pos, field_4_color4); pos += 4;

            listener.AfterRecordSerialize(pos, RecordId, pos - offset, this);
            return(RecordSize);
        }
        public override int Serialize(int offset, byte[] data,
                                      EscherSerializationListener listener)
        {
            listener.BeforeRecordSerialize(offset, RecordId, this);

            LittleEndian.PutShort(data, offset, Options);
            LittleEndian.PutShort(data, offset + 2, RecordId);
            LittleEndian.PutInt(data, offset + 4, PropertiesSize);
            int pos = offset + 8;

            foreach (EscherProperty property in properties)
            {
                pos += property.SerializeSimplePart(data, pos);
            }
            foreach (EscherProperty property in properties)
            {
                pos += property.SerializeComplexPart(data, pos);
            }
            listener.AfterRecordSerialize(pos, RecordId, pos - offset, this);
            return(pos - offset);
        }
        /// <summary>
        /// This method Serializes this escher record into a byte array
        /// </summary>
        /// <param name="offset">The offset into data
        ///  to start writing the record data to.</param>
        /// <param name="data">The byte array to Serialize to.</param>
        /// <returns>The number of bytes written.</returns>
        public override int Serialize(int offset, byte[] data, EscherSerializationListener listener)
        {
            listener.BeforeRecordSerialize(offset, RecordId, this);

            LittleEndian.PutShort(data, offset, Options);
            LittleEndian.PutShort(data, offset + 2, RecordId);
            LittleEndian.PutInt(data, offset + 4, PropertiesSize);
            int pos = offset + 8;
            for (IEnumerator iterator = properties.GetEnumerator(); iterator.MoveNext(); )
            {
                EscherProperty escherProperty = (EscherProperty)iterator.Current;
                pos += escherProperty.SerializeSimplePart(data, pos);
            }
            for (IEnumerator iterator = properties.GetEnumerator(); iterator.MoveNext(); )
            {
                EscherProperty escherProperty = (EscherProperty)iterator.Current;
                pos += escherProperty.SerializeComplexPart(data, pos);
            }
            listener.AfterRecordSerialize(pos, RecordId, pos - offset, this);
            return pos - offset;
        }
Example #26
0
        /// <summary>
        /// Writes this record and any contained records to the supplied byte
        /// </summary>
        /// <param name="offset"></param>
        /// <param name="data"></param>
        /// <param name="listener">a listener for begin and end serialization events.</param>
        /// <returns>the number of bytes written.</returns>
        public override int Serialize(int offset, byte[] data, EscherSerializationListener listener)
        {
            listener.BeforeRecordSerialize(offset, RecordId, this);

            LittleEndian.PutShort(data, offset, Options);
            LittleEndian.PutShort(data, offset + 2, RecordId);
            int remainingBytes = _thedata.Length;

            LittleEndian.PutInt(data, offset + 4, remainingBytes);
            Array.Copy(_thedata, 0, data, offset + 8, _thedata.Length);
            int pos = offset + 8 + _thedata.Length;

            listener.AfterRecordSerialize(pos, RecordId, pos - offset, this);
            int size = pos - offset;

            if (size != RecordSize)
            {
                throw new RecordFormatException(size + " bytes written but RecordSize reports " + RecordSize);
            }
            return(size);
        }
Example #27
0
        /// <summary>
        /// This method Serializes this escher record into a byte array
        /// </summary>
        /// <param name="offset">The offset into data
        ///  to start writing the record data to.</param>
        /// <param name="data">The byte array to Serialize to.</param>
        /// <returns>The number of bytes written.</returns>
        public override int Serialize(int offset, byte[] data, EscherSerializationListener listener)
        {
            listener.BeforeRecordSerialize(offset, RecordId, this);

            LittleEndian.PutShort(data, offset, Options);
            LittleEndian.PutShort(data, offset + 2, RecordId);
            LittleEndian.PutInt(data, offset + 4, PropertiesSize);
            int pos = offset + 8;

            for (IEnumerator iterator = properties.GetEnumerator(); iterator.MoveNext();)
            {
                EscherProperty escherProperty = (EscherProperty)iterator.Current;
                pos += escherProperty.SerializeSimplePart(data, pos);
            }
            for (IEnumerator iterator = properties.GetEnumerator(); iterator.MoveNext();)
            {
                EscherProperty escherProperty = (EscherProperty)iterator.Current;
                pos += escherProperty.SerializeComplexPart(data, pos);
            }
            listener.AfterRecordSerialize(pos, RecordId, pos - offset, this);
            return(pos - offset);
        }
Example #28
0
        /// <summary>
        /// Serializes to an existing byte array without serialization listener.
        /// This is done by delegating to Serialize(int, byte[], EscherSerializationListener).
        /// </summary>
        /// <param name="offset">the offset within the data byte array.</param>
        /// <param name="data"> the data array to Serialize to.</param>
        /// <param name="listener">a listener for begin and end serialization events.</param>
        /// <returns>The number of bytes written.</returns>
        public override int Serialize(int offset, byte[] data, EscherSerializationListener listener)
        {
            listener.BeforeRecordSerialize(offset, RecordId, this);

            LittleEndian.PutShort(data, offset, Options);
            LittleEndian.PutShort(data, offset + 2, RecordId);
            int remainingBytes = 0;
            for (IEnumerator iterator = ChildRecords.GetEnumerator(); iterator.MoveNext(); )
            {
                EscherRecord r = (EscherRecord)iterator.Current;
                remainingBytes += r.RecordSize;
            }
            LittleEndian.PutInt(data, offset + 4, remainingBytes);
            int pos = offset + 8;
            for (IEnumerator iterator = ChildRecords.GetEnumerator(); iterator.MoveNext(); )
            {
                EscherRecord r = (EscherRecord)iterator.Current;
                pos += r.Serialize(pos, data,listener);
            }

            listener.AfterRecordSerialize(pos, RecordId, pos - offset, this);
            return pos - offset;
        }
Example #29
0
 /// <summary>
 /// Serializes the record to an existing byte array.
 /// </summary>
 /// <param name="offset">the offset within the byte array.</param>
 /// <param name="data">the offset within the byte array</param>
 /// <param name="listener">a listener for begin and end serialization events.  This.
 /// is useful because the serialization is
 /// hierarchical/recursive and sometimes you need to be able
 /// break into that.
 /// </param>
 /// <returns></returns>
 public abstract int Serialize(int offset, byte[] data, EscherSerializationListener listener);
        /// <summary>
        /// This method Serializes this escher record into a byte array.
        /// </summary>
        /// <param name="offset">The offset into data to start writing the record data to.</param>
        /// <param name="data">The byte array to Serialize to.</param>
        /// <param name="listener">a listener for begin and end serialization events.</param>
        /// <returns>The number of bytes written.</returns>
        public override int Serialize(int offset, byte[] data, EscherSerializationListener listener)
        {
            listener.BeforeRecordSerialize(offset, RecordId, this);

            if (remainingData == null) remainingData = new byte[0];
            LittleEndian.PutShort(data, offset, Options);
            LittleEndian.PutShort(data, offset + 2, RecordId);
            int remainingBytes = remainingData.Length + (shortRecord ? 8 : 18);
            LittleEndian.PutInt(data, offset + 4, remainingBytes);
            LittleEndian.PutShort(data, offset + 8, field_1_flag);
            LittleEndian.PutShort(data, offset + 10, field_2_col1);
            LittleEndian.PutShort(data, offset + 12, field_3_dx1);
            LittleEndian.PutShort(data, offset + 14, field_4_row1);
            if (!shortRecord)
            {
                LittleEndian.PutShort(data, offset + 16, field_5_dy1);
                LittleEndian.PutShort(data, offset + 18, field_6_col2);
                LittleEndian.PutShort(data, offset + 20, field_7_dx2);
                LittleEndian.PutShort(data, offset + 22, field_8_row2);
                LittleEndian.PutShort(data, offset + 24, field_9_dy2);
            }
            Array.Copy(remainingData, 0, data, offset + (shortRecord ? 16 : 26), remainingData.Length);
            int pos = offset + 8 + (shortRecord ? 8 : 18) + remainingData.Length;

            listener.AfterRecordSerialize(pos, RecordId, pos - offset, this);
            return pos - offset;
        }
 public override int Serialize(int offset, byte[] data, EscherSerializationListener listener)
 { return 0; }
Example #32
0
        /// <summary>
        /// This method Serializes this escher record into a byte array.
        /// @param offset   
        /// </summary>
        /// <param name="offset">The offset into data to start writing the record data to.</param>
        /// <param name="data">the data array to Serialize to</param>
        /// <param name="listener">a listener for begin and end serialization events.</param>
        /// <returns>the number of bytes written.</returns>
        public override int Serialize(int offset, byte[] data, EscherSerializationListener listener)
        {
            listener.BeforeRecordSerialize(offset, RecordId, this);

            LittleEndian.PutShort(data, offset, Options);
            LittleEndian.PutShort(data, offset + 2, RecordId);
            int remainingBytes = field_12_data.Length + 36;
            LittleEndian.PutInt(data, offset + 4, remainingBytes);

            int pos = offset + HEADER_SIZE;
            Array.Copy(field_1_secondaryUID, 0, data, pos, 16); pos += 16;
            LittleEndian.PutInt(data, pos, field_2_cacheOfSize); pos += 4;
            LittleEndian.PutInt(data, pos, field_3_boundaryTop); pos += 4;
            LittleEndian.PutInt(data, pos, field_4_boundaryLeft); pos += 4;
            LittleEndian.PutInt(data, pos, field_5_boundaryWidth); pos += 4;
            LittleEndian.PutInt(data, pos, field_6_boundaryHeight); pos += 4;
            LittleEndian.PutInt(data, pos, field_7_width); pos += 4;
            LittleEndian.PutInt(data, pos, field_8_height); pos += 4;
            LittleEndian.PutInt(data, pos, field_9_cacheOfSavedSize); pos += 4;
            data[pos++] = field_10_compressionFlag;
            data[pos++] = field_11_filter;
            Array.Copy(field_12_data, 0, data, pos, field_12_data.Length); pos += field_12_data.Length;

            listener.AfterRecordSerialize(pos, RecordId, pos - offset, this);
            return pos - offset;
        }
Example #33
0
        /// <summary>
        /// This method Serializes this escher record into a byte array.
        /// </summary>
        /// <param name="offset">The offset into data to start writing the record data to.</param>
        /// <param name="data">The byte array to Serialize to.</param>
        /// <returns>The number of bytes written.</returns>
        public override int Serialize(int offset, byte[] data, EscherSerializationListener listener)
        {
            listener.BeforeRecordSerialize(offset, RecordId, this);

            int pos = offset;
            LittleEndian.PutShort(data, pos, Options); pos += 2;
            LittleEndian.PutShort(data, pos, RecordId); pos += 2;
            int remainingBytes = RecordSize - 8;
            LittleEndian.PutInt(data, pos, remainingBytes); pos += 4;

            LittleEndian.PutInt(data, pos, field_1_shapeIdMax); pos += 4;
            LittleEndian.PutInt(data, pos, NumIdClusters); pos += 4;
            LittleEndian.PutInt(data, pos, field_3_numShapesSaved); pos += 4;
            LittleEndian.PutInt(data, pos, field_4_drawingsSaved); pos += 4;
            for (int i = 0; i < field_5_fileIdClusters.Length; i++)
            {
                LittleEndian.PutInt(data, pos, field_5_fileIdClusters[i].DrawingGroupId); pos += 4;
                LittleEndian.PutInt(data, pos, field_5_fileIdClusters[i].NumShapeIdsUsed); pos += 4;
            }

            listener.AfterRecordSerialize(pos, RecordId, RecordSize, this);
            return RecordSize;
        }
Example #34
0
 /// <summary>
 /// Serializes the record to an existing byte array.
 /// </summary>
 /// <param name="offset">the offset within the byte array.</param>
 /// <param name="data">the offset within the byte array</param>
 /// <param name="listener">a listener for begin and end serialization events.  This.
 /// is useful because the serialization is
 /// hierarchical/recursive and sometimes you need to be able
 /// break into that.
 /// </param>
 /// <returns></returns>
 public abstract int Serialize(int offset, byte[] data, EscherSerializationListener listener);
Example #35
0
        /// <summary>
        /// This method Serializes this escher record into a byte array.  
        /// </summary>
        /// <param name="offset">The offset into 
        /// data to start writing the record data to</param>
        /// <param name="data">The byte array to Serialize to.</param>
        /// <param name="listener">a listener for begin and end serialization events.</param>
        /// <returns>The number of bytes written.</returns>
        public override int Serialize(int offset, byte[] data, EscherSerializationListener listener)
        {
            listener.BeforeRecordSerialize(offset, RecordId, this);

            if (_remainingData == null)
                _remainingData = new byte[0];

            LittleEndian.PutShort(data, offset, Options);
            LittleEndian.PutShort(data, offset + 2, RecordId);
            if (_remainingData == null) _remainingData = new byte[0];
            int blipSize = field_12_blipRecord == null ? 0 : field_12_blipRecord.RecordSize;
            int remainingBytes = _remainingData.Length + 36 + blipSize;
            LittleEndian.PutInt(data, offset + 4, remainingBytes);

            data[offset + 8] = field_1_blipTypeWin32;
            data[offset + 9] = field_2_blipTypeMacOS;
            for (int i = 0; i < 16; i++)
                data[offset + 10 + i] = field_3_uid[i];
            LittleEndian.PutShort(data, offset + 26, field_4_tag);
            LittleEndian.PutInt(data, offset + 28, field_5_size);
            LittleEndian.PutInt(data, offset + 32, field_6_ref);
            LittleEndian.PutInt(data, offset + 36, field_7_offset);
            data[offset + 40] = field_8_usage;
            data[offset + 41] = field_9_name;
            data[offset + 42] = field_10_unused2;
            data[offset + 43] = field_11_unused3;
            int bytesWritten = 0;
            if (field_12_blipRecord != null)
            {
                bytesWritten = field_12_blipRecord.Serialize(offset + 44, data);
            }
            if (_remainingData == null)
                _remainingData = new byte[0];
            Array.Copy(_remainingData, 0, data, offset + 44 + bytesWritten, _remainingData.Length);
            int pos = offset + 8 + 36 + _remainingData.Length + bytesWritten;

            listener.AfterRecordSerialize(pos, RecordId, pos - offset, this);
            return pos - offset;
        }
        /// <summary>
        /// Serializes the record to an existing byte array.
        /// </summary>
        /// <param name="offset">the offset within the byte array</param>
        /// <param name="data">the data array to Serialize to</param>
        /// <param name="listener">a listener for begin and end serialization events.</param>
        /// <returns>the number of bytes written.</returns>
        public override int Serialize(int offset, byte[] data, EscherSerializationListener listener)
        {
            listener.BeforeRecordSerialize(offset, RecordId, this);

            int pos = offset;
            LittleEndian.PutShort(data, pos, Options); pos += 2;
            LittleEndian.PutShort(data, pos, RecordId); pos += 2;
            LittleEndian.PutInt(data, RecordSize - HEADER_SIZE); pos += 4;

            Array.Copy(field_1_UID, 0, data, pos, 16); pos += 16;
            LittleEndian.PutInt(data, pos, field_2_cb); pos += 4;
            LittleEndian.PutInt(data, pos, field_3_rcBounds_x1); pos += 4;
            LittleEndian.PutInt(data, pos, field_3_rcBounds_y1); pos += 4;
            LittleEndian.PutInt(data, pos, field_3_rcBounds_x2); pos += 4;
            LittleEndian.PutInt(data, pos, field_3_rcBounds_y2); pos += 4;
            LittleEndian.PutInt(data, pos, field_4_ptSize_w); pos += 4;
            LittleEndian.PutInt(data, pos, field_4_ptSize_h); pos += 4;
            LittleEndian.PutInt(data, pos, field_5_cbSave); pos += 4;
            data[pos] = field_6_fCompression; pos++;
            data[pos] = field_7_fFilter; pos++;

            Array.Copy(raw_pictureData, 0, data, pos, raw_pictureData.Length);

            listener.AfterRecordSerialize(offset + RecordSize, RecordId, RecordSize, this);
            return HEADER_SIZE + 16 + 1 + raw_pictureData.Length;
        }
 public override int Serialize(int offset, byte[] data, EscherSerializationListener listener)
 {
     return(0);
 }