/// <summary>
        /// This method deSerializes the record from a byte array.
        /// </summary>
        /// <param name="data"> The byte array containing the escher record information</param>
        /// <param name="offset">The starting offset into data </param>
        /// <param name="recordFactory">May be null since this is not a container record.</param>
        /// <returns>The number of bytes Read from the byte array.</returns>
        public override int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory)
        {
            int bytesRemaining = ReadHeader(data, offset);

            if (IsContainerRecord)
            {
                int bytesWritten = 0;
                thedata       = new byte[0];
                offset       += 8;
                bytesWritten += 8;
                while (bytesRemaining > 0)
                {
                    EscherRecord child             = recordFactory.CreateRecord(data, offset);
                    int          childBytesWritten = child.FillFields(data, offset, recordFactory);
                    bytesWritten   += childBytesWritten;
                    offset         += childBytesWritten;
                    bytesRemaining -= childBytesWritten;
                    ChildRecords.Add(child);
                }
                return(bytesWritten);
            }
            else
            {
                thedata = new byte[bytesRemaining];
                Array.Copy(data, offset + 8, thedata, 0, bytesRemaining);
                return(bytesRemaining + 8);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This method deSerializes the record from a byte array.
        /// </summary>
        /// <param name="data">The byte array containing the escher record information</param>
        /// <param name="offset">The starting offset into</param>
        /// <param name="recordFactory">May be null since this is not a container record.</param>
        /// <returns>
        /// The number of bytes Read from the byte array.
        /// </returns>
        public override int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory)
        {
            int bytesAfterHeader = ReadHeader(data, offset);
            int pos = offset + HEADER_SIZE;

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

            raw_pictureData = new byte[field_5_cbSave];
            Array.Copy(data, pos, raw_pictureData, 0, field_5_cbSave);

            // 0 means DEFLATE compression
            // 0xFE means no compression
            if (field_6_fCompression == 0)
            {
                field_pictureData = InflatePictureData(raw_pictureData);
            }
            else
            {
                field_pictureData = raw_pictureData;
            }

            return bytesAfterHeader + HEADER_SIZE;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// This method deSerializes the record from a byte array.
        /// </summary>
        /// <param name="data">The byte array containing the escher record information</param>
        /// <param name="offset">The starting offset into data</param>
        /// <param name="recordFactory">May be null since this is not a container record.</param>
        /// <returns>The number of bytes Read from the byte array.</returns>
        public override int FillFields(byte[] data, int offset,
                                       EscherRecordFactory recordFactory
                                       )
        {
            int bytesRemaining = ReadHeader(data, offset);
            int pos            = offset + 8;

            field_1_blipTypeWin32 = data[pos];
            field_2_blipTypeMacOS = data[pos + 1];
            field_3_uid           = new byte[16];
            Array.Copy(data, pos + 2, field_3_uid, 0, 16);
            field_4_tag      = LittleEndian.GetShort(data, pos + 18);
            field_5_size     = LittleEndian.GetInt(data, pos + 20);
            field_6_ref      = LittleEndian.GetInt(data, pos + 24);
            field_7_offset   = LittleEndian.GetInt(data, pos + 28);
            field_8_usage    = data[pos + 32];
            field_9_name     = data[pos + 33];
            field_10_unused2 = data[pos + 34];
            field_11_unused3 = data[pos + 35];
            bytesRemaining  -= 36;
            int bytesRead = 0;

            if (bytesRemaining > 0)
            {
                field_12_blipRecord = (EscherBlipRecord)recordFactory.CreateRecord(data, pos + 36);
                bytesRead           = field_12_blipRecord.FillFields(data, pos + 36, recordFactory);
            }
            pos            += 36 + bytesRead;
            bytesRemaining -= bytesRead;

            _remainingData = new byte[bytesRemaining];
            Array.Copy(data, pos, _remainingData, 0, bytesRemaining);
            return(bytesRemaining + 8 + 36 + (field_12_blipRecord == null ? 0 : field_12_blipRecord.RecordSize));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// This method deSerializes the record from a byte array.
        /// </summary>
        /// <param name="data">The byte array containing the escher record information</param>
        /// <param name="offset">The starting offset into</param>
        /// <param name="recordFactory">May be null since this is not a container record.</param>
        /// <returns>
        /// The number of bytes Read from the byte array.
        /// </returns>
        public override int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory)
        {
            int bytesAfterHeader = ReadHeader(data, offset);
            int pos = offset + HEADER_SIZE;

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

            raw_pictureData = new byte[field_5_cbSave];
            Array.Copy(data, pos, raw_pictureData, 0, field_5_cbSave);

            // 0 means DEFLATE compression
            // 0xFE means no compression
            if (field_6_fCompression == 0)
            {
                field_pictureData = InflatePictureData(raw_pictureData);
            }
            else
            {
                field_pictureData = raw_pictureData;
            }

            return(bytesAfterHeader + HEADER_SIZE);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// This method deSerializes the record from a byte array.
        /// </summary>
        /// <param name="data">The byte array containing the escher record information</param>
        /// <param name="offset">The starting offset into data</param>
        /// <param name="recordFactory">May be null since this is not a container record.</param>
        /// <returns>The number of bytes Read from the byte array.</returns>
        public override int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory)
        {
            int bytesRemaining = ReadHeader(data, offset);
            int pos            = offset + 8;
            int size           = 0;

            field_1_shapeIdMax = LittleEndian.GetInt(data, pos + size); size += 4;
            int field_2_numIdClusters = LittleEndian.GetInt(data, pos + size); size += 4;

            field_3_numShapesSaved = LittleEndian.GetInt(data, pos + size); size += 4;
            field_4_drawingsSaved  = LittleEndian.GetInt(data, pos + size); size += 4;
            field_5_fileIdClusters = new FileIdCluster[(bytesRemaining - size) / 8];  // Can't rely on field_2_numIdClusters
            for (int i = 0; i < field_5_fileIdClusters.Length; i++)
            {
                field_5_fileIdClusters[i] = new FileIdCluster(LittleEndian.GetInt(data, pos + size), LittleEndian.GetInt(data, pos + size + 4));
                maxDgId = Math.Max(maxDgId, field_5_fileIdClusters[i].DrawingGroupId);
                size   += 8;
            }
            bytesRemaining -= size;
            if (bytesRemaining != 0)
            {
                throw new RecordFormatException("Expecting no remaining data but got " + bytesRemaining + " byte(s).");
            }
            return(8 + size + bytesRemaining);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// This method deserializes the record from a byte array.
        /// </summary>
        /// <param name="data">The byte array containing the escher record information</param>
        /// <param name="offset">The starting offset into</param>
        /// <param name="recordFactory">May be null since this is not a container record.</param>
        /// <returns>
        /// The number of bytes Read from the byte array.
        /// </returns>
        public override int FillFields(byte[] data, int offset,
                                  EscherRecordFactory recordFactory
                                  )
        {
            int bytesAfterHeader = ReadHeader(data, offset);
            int pos = offset + HEADER_SIZE;

            int size = 0;
            field_1_secondaryUID = new byte[16];
            Array.Copy(data, pos + size, field_1_secondaryUID, 0, 16); size += 16;
            field_2_cacheOfSize = LittleEndian.GetInt(data, pos + size); size += 4;
            field_3_boundaryTop = LittleEndian.GetInt(data, pos + size); size += 4;
            field_4_boundaryLeft = LittleEndian.GetInt(data, pos + size); size += 4;
            field_5_boundaryWidth = LittleEndian.GetInt(data, pos + size); size += 4;
            field_6_boundaryHeight = LittleEndian.GetInt(data, pos + size); size += 4;
            field_7_width = LittleEndian.GetInt(data, pos + size); size += 4;
            field_8_height = LittleEndian.GetInt(data, pos + size); size += 4;
            field_9_cacheOfSavedSize = LittleEndian.GetInt(data, pos + size); size += 4;
            field_10_compressionFlag = data[pos + size]; size++;
            field_11_filter = data[pos + size]; size++;

            int bytesRemaining = bytesAfterHeader - size;
            field_12_data = new byte[bytesRemaining];
            Array.Copy(data, pos + size, field_12_data, 0, bytesRemaining);
            size += bytesRemaining;

            return HEADER_SIZE + size;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// This method deSerializes the record from a byte array.
        /// </summary>
        /// <param name="data">The byte array containing the escher record information</param>
        /// <param name="offset">The starting offset into data</param>
        /// <param name="recordFactory">May be null since this is not a container record.</param>
        /// <returns>The number of bytes Read from the byte array.</returns>
        public override int FillFields(byte[] data, int offset,
                                  EscherRecordFactory recordFactory
                                  )
        {
            int bytesRemaining = ReadHeader(data, offset);
            int pos = offset + 8;
            field_1_blipTypeWin32 = data[pos];
            field_2_blipTypeMacOS = data[pos + 1];
            field_3_uid = new byte[16];
            Array.Copy(data, pos + 2, field_3_uid, 0, 16);
            field_4_tag = LittleEndian.GetShort(data, pos + 18);
            field_5_size = LittleEndian.GetInt(data, pos + 20);
            field_6_ref = LittleEndian.GetInt(data, pos + 24);
            field_7_offset = LittleEndian.GetInt(data, pos + 28);
            field_8_usage = data[pos + 32];
            field_9_name = data[pos + 33];
            field_10_unused2 = data[pos + 34];
            field_11_unused3 = data[pos + 35];
            bytesRemaining -= 36;
            int bytesRead = 0;
            if (bytesRemaining > 0)
            {
                field_12_blipRecord = (EscherBlipRecord)recordFactory.CreateRecord(data, pos + 36);
                bytesRead = field_12_blipRecord.FillFields(data, pos + 36, recordFactory);
            }
            pos += 36 + bytesRead;
            bytesRemaining -= bytesRead;

            _remainingData = new byte[bytesRemaining];
            Array.Copy(data, pos, _remainingData, 0, bytesRemaining);
            return bytesRemaining + 8 + 36 + (field_12_blipRecord == null ? 0 : field_12_blipRecord.RecordSize);

        }
 /// <summary>
 /// This method deSerializes the record from a byte array.
 /// </summary>
 /// <param name="data"> The byte array containing the escher record information</param>
 /// <param name="offset">The starting offset into data </param>
 /// <param name="recordFactory">May be null since this is not a container record.</param>
 /// <returns>The number of bytes Read from the byte array.</returns>
 public override int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory)
 {
     int bytesRemaining = ReadHeader(data, offset);
     if (IsContainerRecord)
     {
         int bytesWritten = 0;
         thedata = new byte[0];
         offset += 8;
         bytesWritten += 8;
         while (bytesRemaining > 0)
         {
             EscherRecord child = recordFactory.CreateRecord(data, offset);
             int childBytesWritten = child.FillFields(data, offset, recordFactory);
             bytesWritten += childBytesWritten;
             offset += childBytesWritten;
             bytesRemaining -= childBytesWritten;
             ChildRecords.Add(child);
         }
         return bytesWritten;
     }
     else
     {
         thedata = new byte[bytesRemaining];
         Array.Copy(data, offset + 8, thedata, 0, bytesRemaining);
         return bytesRemaining + 8;
     }
 }
Ejemplo n.º 9
0
        /// <summary>
        /// This method deserializes the record from a byte array.
        /// </summary>
        /// <param name="data">The byte array containing the escher record information</param>
        /// <param name="offset">The starting offset into</param>
        /// <param name="recordFactory">May be null since this is not a container record.</param>
        /// <returns>
        /// The number of bytes Read from the byte array.
        /// </returns>
        public override int FillFields(byte[] data, int offset,
                                       EscherRecordFactory recordFactory
                                       )
        {
            int bytesAfterHeader = ReadHeader(data, offset);
            int pos = offset + HEADER_SIZE;

            int size = 0;

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

            int bytesRemaining = bytesAfterHeader - size;

            field_12_data = new byte[bytesRemaining];
            Array.Copy(data, pos + size, field_12_data, 0, bytesRemaining);
            size += bytesRemaining;

            return(HEADER_SIZE + size);
        }
Ejemplo n.º 10
0
 /// <summary>
 /// This method deSerializes the record from a byte array.
 /// </summary>
 /// <param name="data">The byte array containing the escher record information</param>
 /// <param name="offset">The starting offset into data</param>
 /// <param name="recordFactory">May be null since this is not a container record.</param>
 /// <returns>The number of bytes Read from the byte array.</returns>
 public override int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory)
 {
     int bytesRemaining = ReadHeader(data, offset);
     int pos = offset + 8;
     remainingData = new byte[bytesRemaining];
     Array.Copy(data, pos, remainingData, 0, bytesRemaining);
     return 8 + bytesRemaining;
 }
Ejemplo n.º 11
0
        /// <summary>
        /// This method deSerializes the record from a byte array.
        /// </summary>
        /// <param name="data">The byte array containing the escher record information</param>
        /// <param name="offset">The starting offset into data</param>
        /// <param name="recordFactory">May be null since this is not a container record.</param>
        /// <returns>The number of bytes Read from the byte array.</returns>
        public override int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory)
        {
            int bytesRemaining = ReadHeader(data, offset);
            int pos            = offset + 8;

            remainingData = new byte[bytesRemaining];
            Array.Copy(data, pos, remainingData, 0, bytesRemaining);
            return(8 + bytesRemaining);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// This method deSerializes the record from a byte array.
        /// </summary>
        /// <param name="data">The byte array containing the escher record information</param>
        /// <param name="offset">The starting offset into data</param>
        /// <param name="recordFactory">May be null since this is not a container record.</param>
        /// <returns>The number of bytes Read from the byte array.</returns>
        public override int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory)
        {
            int bytesRemaining = ReadHeader(data, offset);
            int pos = offset + 8;

            EscherPropertyFactory f = new EscherPropertyFactory();
            properties = (ArrayList)f.CreateProperties(data, pos, GetInstance());
            return bytesRemaining + 8;
        }
Ejemplo n.º 13
0
        /// <summary>
        /// This method deSerializes the record from a byte array.
        /// </summary>
        /// <param name="data">The byte array containing the escher record information</param>
        /// <param name="offset">The starting offset into data</param>
        /// <param name="recordFactory">May be null since this is not a container record.</param>
        /// <returns>The number of bytes Read from the byte array.</returns>
        public override int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory)
        {
            int bytesRemaining = ReadHeader(data, offset);
            int pos            = offset + 8;

            EscherPropertyFactory f = new EscherPropertyFactory();

            properties = (ArrayList)f.CreateProperties(data, pos, GetInstance());
            return(bytesRemaining + 8);
        }
Ejemplo n.º 14
0
        /**
         * This method deserializes the record from a byte array.
         *
         * @param data          The byte array containing the escher record information
         * @param offset        The starting offset into <c>data</c>.
         * @param recordFactory May be null since this is not a container record.
         * @return The number of bytes Read from the byte array.
         */
        public override int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory)
        {
            int bytesRemaining = ReadHeader(data, offset);

            // Save the data, Ready for the calling code to do something
            //  useful with it
            thedata = new byte[bytesRemaining];
            Array.Copy(data, offset + 8, thedata, 0, bytesRemaining);
            return(bytesRemaining + 8);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// This method deSerializes the record from a byte array.
        /// </summary>
        /// <param name="data">The byte array containing the escher record information</param>
        /// <param name="offset">The starting offset into </param>
        /// <param name="recordFactory">May be null since this is not a container record.</param>
        /// <returns>The number of bytes Read from the byte array.</returns>
        public override int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory)
        {
            int bytesAfterHeader = ReadHeader(data, offset);
            int pos = offset + HEADER_SIZE;

            field_pictureData = new byte[bytesAfterHeader];
            Array.Copy(data, pos, field_pictureData, 0, bytesAfterHeader);

            return bytesAfterHeader + 8;
        }
Ejemplo n.º 16
0
        /**
         * This method deserializes the record from a byte array.
         *
         * @param data          The byte array containing the escher record information
         * @param offset        The starting offset into <c>data</c>.
         * @param recordFactory May be null since this is not a container record.
         * @return The number of bytes Read from the byte array.
         */
        public override int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory)
        {
            int bytesRemaining = ReadHeader(data, offset);

            // Save the data, Ready for the calling code to do something
            //  useful with it
            thedata = new byte[bytesRemaining];
            Array.Copy(data, offset + 8, thedata, 0, bytesRemaining);
            return bytesRemaining + 8;
        }
Ejemplo n.º 17
0
        /// <summary>
        /// This method deSerializes the record from a byte array.
        /// </summary>
        /// <param name="data">The byte array containing the escher record information</param>
        /// <param name="offset">The starting offset into </param>
        /// <param name="recordFactory">May be null since this is not a container record.</param>
        /// <returns>The number of bytes Read from the byte array.</returns>
        public override int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory)
        {
            int bytesAfterHeader = ReadHeader(data, offset);
            int pos = offset + HEADER_SIZE;

            field_pictureData = new byte[bytesAfterHeader];
            Array.Copy(data, pos, field_pictureData, 0, bytesAfterHeader);

            return(bytesAfterHeader + 8);
        }
 /// <summary>
 /// This method deSerializes the record from a byte array.
 /// </summary>
 /// <param name="data">The byte array containing the escher record information</param>
 /// <param name="offset">The starting offset into data</param>
 /// <param name="recordFactory">May be null since this is not a container record.</param>
 /// <returns>The number of bytes Read from the byte array.</returns>
 public override int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory)
 {
     int bytesRemaining = ReadHeader(data, offset);
     int pos = offset + 8;
     int size = 0;
     field_1_dx1 = LittleEndian.GetInt(data, pos + size); size += 4;
     field_2_dy1 = LittleEndian.GetInt(data, pos + size); size += 4;
     field_3_dx2 = LittleEndian.GetInt(data, pos + size); size += 4;
     field_4_dy2 = LittleEndian.GetInt(data, pos + size); size += 4;
     return 8 + size;
 }
Ejemplo n.º 19
0
 /// <summary>
 /// This method deSerializes the record from a byte array.
 /// </summary>
 /// <param name="data">The byte array containing the escher record information</param>
 /// <param name="offset">The starting offset into data</param>
 /// <param name="recordFactory">May be null since this is not a container record.</param>
 /// <returns>The number of bytes Read from the byte array.</returns>
 public override int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory)
 {
     int bytesRemaining = ReadHeader(data, offset);
     int pos = offset + 8;
     int size = 0;
     field_1_numShapes = LittleEndian.GetInt(data, pos + size); size += 4;
     field_2_lastMSOSPID = LittleEndian.GetInt(data, pos + size); size += 4;
     //        bytesRemaining -= size;
     //        remainingData  =  new byte[bytesRemaining];
     //        Array.Copy( data, pos + size, remainingData, 0, bytesRemaining );
     return RecordSize;
 }
Ejemplo n.º 20
0
        /// <summary>
        /// This method deSerializes the record from a byte array.
        /// </summary>
        /// <param name="data">The byte array containing the escher record information</param>
        /// <param name="offset">The starting offset into data</param>
        /// <param name="recordFactory">May be null since this is not a container record.</param>
        /// <returns>The number of bytes Read from the byte array.</returns>
        public override int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory)
        {
            int bytesRemaining = ReadHeader(data, offset);
            int pos            = offset + 8;
            int size           = 0;

            field_1_dx1 = LittleEndian.GetInt(data, pos + size); size += 4;
            field_2_dy1 = LittleEndian.GetInt(data, pos + size); size += 4;
            field_3_dx2 = LittleEndian.GetInt(data, pos + size); size += 4;
            field_4_dy2 = LittleEndian.GetInt(data, pos + size); size += 4;
            return(8 + size);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// This method deSerializes the record from a byte array.
        /// </summary>
        /// <param name="data">The byte array containing the escher record information</param>
        /// <param name="offset">The starting offset into data</param>
        /// <param name="recordFactory">May be null since this is not a container record.</param>
        /// <returns>The number of bytes Read from the byte array.</returns>
        public override int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory)
        {
            int bytesRemaining = ReadHeader(data, offset);
            int pos            = offset + 8;
            int size           = 0;

            field_1_numShapes   = LittleEndian.GetInt(data, pos + size); size += 4;
            field_2_lastMSOSPID = LittleEndian.GetInt(data, pos + size); size += 4;
            //        bytesRemaining -= size;
            //        remainingData  =  new byte[bytesRemaining];
            //        Array.Copy( data, pos + size, remainingData, 0, bytesRemaining );
            return(RecordSize);
        }
 /// <summary>
 /// This method deSerializes the record from a byte array.
 /// </summary>
 /// <param name="data">The byte array containing the escher record information</param>
 /// <param name="offset">The starting offset into data</param>
 /// <param name="recordFactory">May be null since this is not a container record.</param>
 /// <returns>The number of bytes Read from the byte array.</returns>
 public override int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory)
 {
     int bytesRemaining = ReadHeader(data, offset);
     int pos = offset + 8;
     int size = 0;
     field_1_color1 = LittleEndian.GetInt(data, pos + size); size += 4;
     field_2_color2 = LittleEndian.GetInt(data, pos + size); size += 4;
     field_3_color3 = LittleEndian.GetInt(data, pos + size); size += 4;
     field_4_color4 = LittleEndian.GetInt(data, pos + size); size += 4;
     bytesRemaining -= size;
     if (bytesRemaining != 0)
         throw new RecordFormatException("Expecting no remaining data but got " + bytesRemaining + " byte(s).");
     return 8 + size + bytesRemaining;
 }
Ejemplo n.º 23
0
        /// <summary>
        /// This method deSerializes the record from a byte array.    
        /// </summary>
        /// <param name="data"> The byte array containing the escher record information</param>
        /// <param name="offset">The starting offset into </param>
        /// <param name="recordFactory">May be null since this is not a container record.</param>
        /// <returns>The number of bytes Read from the byte array.</returns>
        public override int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory)
        {
            int bytesAfterHeader = ReadHeader(data, offset);
            int pos = offset + HEADER_SIZE;

            field_1_UID = new byte[16];
            Array.Copy(data, pos, field_1_UID, 0, 16); pos += 16;
            field_2_marker = data[pos]; pos++;

            field_pictureData = new byte[bytesAfterHeader - 17];
            Array.Copy(data, pos, field_pictureData, 0, field_pictureData.Length);

            return bytesAfterHeader + HEADER_SIZE;
        }
Ejemplo n.º 24
0
        /// <summary>
        /// This method deSerializes the record from a byte array.
        /// </summary>
        /// <param name="data"> The byte array containing the escher record information</param>
        /// <param name="offset">The starting offset into </param>
        /// <param name="recordFactory">May be null since this is not a container record.</param>
        /// <returns>The number of bytes Read from the byte array.</returns>
        public override int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory)
        {
            int bytesAfterHeader = ReadHeader(data, offset);
            int pos = offset + HEADER_SIZE;

            field_1_UID = new byte[16];
            Array.Copy(data, pos, field_1_UID, 0, 16); pos += 16;
            field_2_marker = data[pos]; pos++;

            field_pictureData = new byte[bytesAfterHeader - 17];
            Array.Copy(data, pos, field_pictureData, 0, field_pictureData.Length);

            return(bytesAfterHeader + HEADER_SIZE);
        }
Ejemplo n.º 25
0
 /// <summary>
 /// This method deSerializes the record from a byte array.
 /// </summary>
 /// <param name="data">The byte array containing the escher record information</param>
 /// <param name="offset">The starting offset into data</param>
 /// <param name="recordFactory">May be null since this is not a container record.</param>
 /// <returns>The number of bytes Read from the byte array.</returns>
 public override int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory)
 {
     int bytesRemaining = ReadHeader(data, offset);
     int pos = offset + 8;
     int size = 0;
     field_1_rectX1 = LittleEndian.GetInt(data, pos + size); size += 4;
     field_2_rectY1 = LittleEndian.GetInt(data, pos + size); size += 4;
     field_3_rectX2 = LittleEndian.GetInt(data, pos + size); size += 4;
     field_4_rectY2 = LittleEndian.GetInt(data, pos + size); size += 4;
     bytesRemaining -= size;
     if (bytesRemaining != 0) throw new RecordFormatException("Expected no remaining bytes but got " + bytesRemaining);
     //        remainingData  =  new byte[bytesRemaining];
     //        Array.Copy( data, pos + size, remainingData, 0, bytesRemaining );
     return 8 + size + bytesRemaining;
 }
Ejemplo n.º 26
0
        /// <summary>
        /// This method deSerializes the record from a byte array.
        /// </summary>
        /// <param name="data">The byte array containing the escher record information</param>
        /// <param name="offset">The starting offset into data</param>
        /// <param name="recordFactory">May be null since this is not a container record.</param>
        /// <returns>The number of bytes Read from the byte array.</returns>
        public override int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory)
        {
            int bytesRemaining = ReadHeader(data, offset);
            int pos            = offset + 8;
            int size           = 0;

            field_1_color1  = LittleEndian.GetInt(data, pos + size); size += 4;
            field_2_color2  = LittleEndian.GetInt(data, pos + size); size += 4;
            field_3_color3  = LittleEndian.GetInt(data, pos + size); size += 4;
            field_4_color4  = LittleEndian.GetInt(data, pos + size); size += 4;
            bytesRemaining -= size;
            if (bytesRemaining != 0)
            {
                throw new RecordFormatException("Expecting no remaining data but got " + bytesRemaining + " byte(s).");
            }
            return(8 + size + bytesRemaining);
        }
Ejemplo n.º 27
0
        /// <summary>
        /// This method deSerializes the record from a byte array.
        /// </summary>
        /// <param name="data">The byte array containing the escher record information</param>
        /// <param name="offset">The starting offset into data</param>
        /// <param name="recordFactory">May be null since this is not a container record.</param>
        /// <returns>The number of bytes Read from the byte array.</returns>
        public override int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory)
        {
            int bytesRemaining = ReadHeader(data, offset);
            int pos            = offset + 8;
            int size           = 0;

            field_1_rectX1  = LittleEndian.GetInt(data, pos + size); size += 4;
            field_2_rectY1  = LittleEndian.GetInt(data, pos + size); size += 4;
            field_3_rectX2  = LittleEndian.GetInt(data, pos + size); size += 4;
            field_4_rectY2  = LittleEndian.GetInt(data, pos + size); size += 4;
            bytesRemaining -= size;
            if (bytesRemaining != 0)
            {
                throw new RecordFormatException("Expected no remaining bytes but got " + bytesRemaining);
            }
            //        remainingData  =  new byte[bytesRemaining];
            //        Array.Copy( data, pos + size, remainingData, 0, bytesRemaining );
            return(8 + size + bytesRemaining);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// This method deSerializes the record from a byte array.
        /// </summary>
        /// <param name="data">The byte array containing the escher record information</param>
        /// <param name="offset">The starting offset into data</param>
        /// <param name="recordFactory">May be null since this is not a container record.</param>
        /// <returns>The number of bytes Read from the byte array.</returns>
        public override int FillFields(byte[] data, int offset,
                                       EscherRecordFactory recordFactory
                                       )
        {
            int bytesRemaining = ReadHeader(data, offset);
            int pos            = offset + 8;

            field_1_blipTypeWin32 = data[pos];
            field_2_blipTypeMacOS = data[pos + 1];
            Array.Copy(data, pos + 2, field_3_uid = new byte[16], 0, 16);
            field_4_tag      = LittleEndian.GetShort(data, pos + 18);
            field_5_size     = LittleEndian.GetInt(data, pos + 20);
            field_6_ref      = LittleEndian.GetInt(data, pos + 24);
            field_7_offset   = LittleEndian.GetInt(data, pos + 28);
            field_8_usage    = data[pos + 32];
            field_9_name     = data[pos + 33];
            field_10_unused2 = data[pos + 34];
            field_11_unused3 = data[pos + 35];
            bytesRemaining  -= 36;
            int bytesRead = 0;

            if (bytesRemaining > 0)
            {
                field_12_blipRecord = (EscherBlipRecord)recordFactory.CreateRecord(data, pos + 36);
                bytesRead           = field_12_blipRecord.FillFields(data, pos + 36, recordFactory);
            }
            pos            += 36 + bytesRead;
            bytesRemaining -= bytesRead;
            //        if (field_1_blipTypeWin32 == BT_PNG)
            //        {
            //            byte[] uid = new byte[16];
            //            Array.Copy( data, pos + 36, uid, 0, 16 );
            //            byte[] puid = new byte[16];
            //            Array.Copy( data, pos + 52, puid, 0, 16 );
            //            byte tag = data[pos+68];
            //            Console.WriteLine( HexDump.dump( data, 0, 0 ) );
            //            byte[] pngBytes = EscherBlipRecord.decompress( data, pos+69, bytesRemaining);
            //        }

            remainingData = new byte[bytesRemaining];
            Array.Copy(data, pos, remainingData, 0, bytesRemaining);
            return(bytesRemaining + 8 + 36 + (field_12_blipRecord == null ? 0 : field_12_blipRecord.RecordSize));
        }
Ejemplo n.º 29
0
        /// <summary>
        /// This method deSerializes the record from a byte array.
        /// </summary>
        /// <param name="data">The byte array containing the escher record information</param>
        /// <param name="offset">The starting offset into data</param>
        /// <param name="recordFactory">May be null since this is not a container record.</param>
        /// <returns>The number of bytes Read from the byte array.</returns>
        public override int FillFields(byte[] data, int offset,
                                  EscherRecordFactory recordFactory
                                  )
        {
            int bytesRemaining = ReadHeader(data, offset);
            int pos = offset + 8;
            field_1_blipTypeWin32 = data[pos];
            field_2_blipTypeMacOS = data[pos + 1];
            Array.Copy(data, pos + 2, field_3_uid = new byte[16], 0, 16);
            field_4_tag = LittleEndian.GetShort(data, pos + 18);
            field_5_size = LittleEndian.GetInt(data, pos + 20);
            field_6_ref = LittleEndian.GetInt(data, pos + 24);
            field_7_offset = LittleEndian.GetInt(data, pos + 28);
            field_8_usage = data[pos + 32];
            field_9_name = data[pos + 33];
            field_10_unused2 = data[pos + 34];
            field_11_unused3 = data[pos + 35];
            bytesRemaining -= 36;
            int bytesRead = 0;
            if (bytesRemaining > 0)
            {
                field_12_blipRecord = (EscherBlipRecord)recordFactory.CreateRecord(data, pos + 36);
                bytesRead = field_12_blipRecord.FillFields(data, pos + 36, recordFactory);
            }
            pos += 36 + bytesRead;
            bytesRemaining -= bytesRead;
            //        if (field_1_blipTypeWin32 == BT_PNG)
            //        {
            //            byte[] uid = new byte[16];
            //            Array.Copy( data, pos + 36, uid, 0, 16 );
            //            byte[] puid = new byte[16];
            //            Array.Copy( data, pos + 52, puid, 0, 16 );
            //            byte tag = data[pos+68];
            //            Console.WriteLine( HexDump.dump( data, 0, 0 ) );
            //            byte[] pngBytes = EscherBlipRecord.decompress( data, pos+69, bytesRemaining);
            //        }

            remainingData = new byte[bytesRemaining];
            Array.Copy(data, pos, remainingData, 0, bytesRemaining);
            return bytesRemaining + 8 + 36 + (field_12_blipRecord == null ? 0 : field_12_blipRecord.RecordSize);

        }
Ejemplo n.º 30
0
 /// <summary>
 /// The contract of this method is to deSerialize an escher record including
 /// it's children.
 /// </summary>
 /// <param name="data">The byte array containing the Serialized escher
 /// records.</param>
 /// <param name="offset">The offset into the byte array.</param>
 /// <param name="recordFactory">A factory for creating new escher records</param>
 /// <returns>The number of bytes written.</returns>        
 public override int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory)
 {
     int bytesRemaining = ReadHeader(data, offset);
     int bytesWritten = 8;
     offset += 8;
     while (bytesRemaining > 0 && offset < data.Length)
     {
         EscherRecord child = recordFactory.CreateRecord(data, offset);
         int childBytesWritten = child.FillFields(data, offset, recordFactory);
         bytesWritten += childBytesWritten;
         offset += childBytesWritten;
         bytesRemaining -= childBytesWritten;
         AddChildRecord(child);
         if (offset >= data.Length && bytesRemaining > 0)
         {
             Console.WriteLine("WARNING: " + bytesRemaining + " bytes remaining but no space left");
         }
     }
     return bytesWritten;
 }
Ejemplo n.º 31
0
 /// <summary>
 /// This method deSerializes the record from a byte array.
 /// </summary>
 /// <param name="data">The byte array containing the escher record information</param>
 /// <param name="offset">The starting offset into data</param>
 /// <param name="recordFactory">May be null since this is not a container record.</param>
 /// <returns>The number of bytes Read from the byte array.</returns>
 public override int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory)
 {
     int bytesRemaining = ReadHeader(data, offset);
     int pos = offset + 8;
     int size = 0;
     field_1_shapeIdMax = LittleEndian.GetInt(data, pos + size); size += 4;
     int field_2_numIdClusters = LittleEndian.GetInt(data, pos + size); size += 4;
     field_3_numShapesSaved = LittleEndian.GetInt(data, pos + size); size += 4;
     field_4_drawingsSaved = LittleEndian.GetInt(data, pos + size); size += 4;
     field_5_fileIdClusters = new FileIdCluster[(bytesRemaining - size) / 8];  // Can't rely on field_2_numIdClusters
     for (int i = 0; i < field_5_fileIdClusters.Length; i++)
     {
         field_5_fileIdClusters[i] = new FileIdCluster(LittleEndian.GetInt(data, pos + size), LittleEndian.GetInt(data, pos + size + 4));
         maxDgId = Math.Max(maxDgId, field_5_fileIdClusters[i].DrawingGroupId);
         size += 8;
     }
     bytesRemaining -= size;
     if (bytesRemaining != 0)
         throw new RecordFormatException("Expecting no remaining data but got " + bytesRemaining + " byte(s).");
     return 8 + size + bytesRemaining;
 }
Ejemplo n.º 32
0
        /// <summary>
        /// The contract of this method is to deSerialize an escher record including
        /// it's children.
        /// </summary>
        /// <param name="data">The byte array containing the Serialized escher
        /// records.</param>
        /// <param name="offset">The offset into the byte array.</param>
        /// <param name="recordFactory">A factory for creating new escher records</param>
        /// <returns>The number of bytes written.</returns>
        public override int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory)
        {
            int bytesRemaining = ReadHeader(data, offset);
            int bytesWritten   = 8;

            offset += 8;
            while (bytesRemaining > 0 && offset < data.Length)
            {
                EscherRecord child             = recordFactory.CreateRecord(data, offset);
                int          childBytesWritten = child.FillFields(data, offset, recordFactory);
                bytesWritten   += childBytesWritten;
                offset         += childBytesWritten;
                bytesRemaining -= childBytesWritten;
                AddChildRecord(child);
                if (offset >= data.Length && bytesRemaining > 0)
                {
                    Console.WriteLine("WARNING: " + bytesRemaining + " bytes remaining but no space left");
                }
            }
            return(bytesWritten);
        }
Ejemplo n.º 33
0
        /// <summary>
        /// This method deSerializes the record from a byte array.
        /// </summary>
        /// <param name="data"> The byte array containing the escher record information</param>
        /// <param name="offset">The starting offset into data </param>
        /// <param name="recordFactory">May be null since this is not a container record.</param>
        /// <returns>The number of bytes Read from the byte array.</returns>
        public override int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory)
        {
            int bytesRemaining = ReadHeader(data, offset);

            /*
             * Modified by Zhang Zhang
             * Have a check between avaliable bytes and bytesRemaining,
             * take the avaliable length if the bytesRemaining out of range.
             * July 09, 2010
             */
            int avaliable = data.Length - (offset + 8);

            if (bytesRemaining > avaliable)
            {
                bytesRemaining = avaliable;
            }
            if (IsContainerRecord)
            {
                int bytesWritten = 0;
                thedata       = new byte[0];
                offset       += 8;
                bytesWritten += 8;
                while (bytesRemaining > 0)
                {
                    EscherRecord child             = recordFactory.CreateRecord(data, offset);
                    int          childBytesWritten = child.FillFields(data, offset, recordFactory);
                    bytesWritten   += childBytesWritten;
                    offset         += childBytesWritten;
                    bytesRemaining -= childBytesWritten;
                    ChildRecords.Add(child);
                }
                return(bytesWritten);
            }
            else
            {
                thedata = new byte[bytesRemaining];
                Array.Copy(data, offset + 8, thedata, 0, bytesRemaining);
                return(bytesRemaining + 8);
            }
        }
Ejemplo n.º 34
0
        /// <summary>
        /// This method deSerializes the record from a byte array.
        /// </summary>
        /// <param name="data"> The byte array containing the escher record information</param>
        /// <param name="offset">The starting offset into data </param>
        /// <param name="recordFactory">May be null since this is not a container record.</param>
        /// <returns>The number of bytes Read from the byte array.</returns>
        public override int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory)
        {
            int bytesRemaining = ReadHeader(data, offset);
            /*
		     * Modified by Zhang Zhang
		     * Have a check between avaliable bytes and bytesRemaining, 
		     * take the avaliable length if the bytesRemaining out of range.
		     * July 09, 2010
		     */
            int avaliable = data.Length - (offset + 8);
            if (bytesRemaining > avaliable)
            {
                bytesRemaining = avaliable;
            }
            if (IsContainerRecord)
            {
                int bytesWritten = 0;
                thedata = new byte[0];
                offset += 8;
                bytesWritten += 8;
                while (bytesRemaining > 0)
                {
                    EscherRecord child = recordFactory.CreateRecord(data, offset);
                    int childBytesWritten = child.FillFields(data, offset, recordFactory);
                    bytesWritten += childBytesWritten;
                    offset += childBytesWritten;
                    bytesRemaining -= childBytesWritten;
                    ChildRecords.Add(child);
                }
                return bytesWritten;
            }
            else
            {
                thedata = new byte[bytesRemaining];
                Array.Copy(data, offset + 8, thedata, 0, bytesRemaining);
                return bytesRemaining + 8;
            }
        }
Ejemplo n.º 35
0
        /// <summary>
        /// This method deSerializes the record from a byte array.
        /// </summary>
        /// <param name="data">The byte array containing the escher record information</param>
        /// <param name="offset">The starting offset into data</param>
        /// <param name="recordFactory">May be null since this is not a container record.</param>
        /// <returns>The number of bytes Read from the byte array.</returns>
        public override int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory)
        {
            int bytesRemaining = ReadHeader(data, offset);
            int pos            = offset + 8;
            int size           = 0;

            // Always find 4 two byte entries. Sometimes find 9
            if (bytesRemaining == 4) // Word format only 4 bytes
            {
                // Not sure exactly what the format is quite yet, likely a reference to a PLC
            }
            else
            {
                field_1_flag = LittleEndian.GetShort(data, pos + size); size += 2;
                field_2_col1 = LittleEndian.GetShort(data, pos + size); size += 2;
                field_3_dx1  = LittleEndian.GetShort(data, pos + size); size += 2;
                field_4_row1 = LittleEndian.GetShort(data, pos + size); size += 2;
                if (bytesRemaining >= 18)
                {
                    field_5_dy1  = LittleEndian.GetShort(data, pos + size); size += 2;
                    field_6_col2 = LittleEndian.GetShort(data, pos + size); size += 2;
                    field_7_dx2  = LittleEndian.GetShort(data, pos + size); size += 2;
                    field_8_row2 = LittleEndian.GetShort(data, pos + size); size += 2;
                    field_9_dy2  = LittleEndian.GetShort(data, pos + size); size += 2;
                    shortRecord  = false;
                }
                else
                {
                    shortRecord = true;
                }
            }
            bytesRemaining -= size;
            remainingData   = new byte[bytesRemaining];
            Array.Copy(data, pos + size, remainingData, 0, bytesRemaining);
            return(8 + size + bytesRemaining);
        }
        /// <summary>
        /// This method deSerializes the record from a byte array.
        /// </summary>
        /// <param name="data">The byte array containing the escher record information</param>
        /// <param name="offset">The starting offset into data</param>
        /// <param name="recordFactory">May be null since this is not a container record.</param>
        /// <returns>The number of bytes Read from the byte array.</returns>
        public override int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory)
        {
            int bytesRemaining = ReadHeader(data, offset);
            int pos = offset + 8;
            int size = 0;

            // Always find 4 two byte entries. Sometimes find 9
            if (bytesRemaining == 4) // Word format only 4 bytes
            {
                // Not sure exactly what the format is quite yet, likely a reference to a PLC
            }
            else
            {
                field_1_flag = LittleEndian.GetShort(data, pos + size); size += 2;
                field_2_col1 = LittleEndian.GetShort(data, pos + size); size += 2;
                field_3_dx1 = LittleEndian.GetShort(data, pos + size); size += 2;
                field_4_row1 = LittleEndian.GetShort(data, pos + size); size += 2;
                if (bytesRemaining >= 18)
                {
                    field_5_dy1 = LittleEndian.GetShort(data, pos + size); size += 2;
                    field_6_col2 = LittleEndian.GetShort(data, pos + size); size += 2;
                    field_7_dx2 = LittleEndian.GetShort(data, pos + size); size += 2;
                    field_8_row2 = LittleEndian.GetShort(data, pos + size); size += 2;
                    field_9_dy2 = LittleEndian.GetShort(data, pos + size); size += 2;
                    shortRecord = false;
                }
                else
                {
                    shortRecord = true;
                }
            }
            bytesRemaining -= size;
            remainingData = new byte[bytesRemaining];
            Array.Copy(data, pos + size, remainingData, 0, bytesRemaining);
            return 8 + size + bytesRemaining;
        }
Ejemplo n.º 37
0
 public override int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory)
 { return 0; }
Ejemplo n.º 38
0
 public override int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory)
 {
     return(0);
 }
Ejemplo n.º 39
0
 /// <summary>
 /// The contract of this method is to deSerialize an escher record including
 /// it's children.
 /// </summary>
 /// <param name="data">The byte array containing the Serialized escher
 /// records.</param>
 /// <param name="offset">The offset into the byte array.</param>
 /// <param name="recordFactory">A factory for creating new escher records.</param>
 /// <returns>The number of bytes written.</returns>
 public abstract int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory);
Ejemplo n.º 40
0
 /// <summary>
 /// Delegates to FillFields(byte[], int, EscherRecordFactory)
 /// </summary>
 /// <param name="data">The data.</param>
 /// <param name="f">The f.</param>
 /// <returns></returns>
 public int FillFields(byte[] data, EscherRecordFactory f)
 {
     return(FillFields(data, 0, f));
 }
Ejemplo n.º 41
0
 /// <summary>
 /// Delegates to FillFields(byte[], int, EscherRecordFactory)
 /// </summary>
 /// <param name="data">The data.</param>
 /// <param name="f">The f.</param>
 /// <returns></returns>
 public int FillFields(byte[] data, EscherRecordFactory f)
 {
     return FillFields(data, 0, f);
 }
Ejemplo n.º 42
0
 /// <summary>
 /// The contract of this method is to deSerialize an escher record including
 /// it's children.
 /// </summary>
 /// <param name="data">The byte array containing the Serialized escher
 /// records.</param>
 /// <param name="offset">The offset into the byte array.</param>
 /// <param name="recordFactory">A factory for creating new escher records.</param>
 /// <returns>The number of bytes written.</returns>       
 public abstract int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory);