Exemplo n.º 1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Read the mark chunk and save the data read to the SA document writer.
        /// </summary>
        /// <returns>true if success. Otherwise, false</returns>
        /// ------------------------------------------------------------------------------------
        public bool ReadMarkChunk()
        {
            try {
                // Go to mark chunk
                if ((m_stream.Position = GetChunkOffset(m_stream, kidMarkChunk)) < 0)
                {
                    return(true);
                }

                // Skip the chunk Id and read the chunk's length.
                m_stream.Position += 4;
                uint markDataLen = m_reader.ReadUInt32();
                uint bytesRead   = 0;

                while (bytesRead < markDataLen)
                {
                    // Read the length for the string.
                    int    labelLen = m_reader.ReadInt16();
                    string label    = new string(Encoding.ASCII.GetChars(m_reader.ReadBytes(labelLen)));

                    // Skip over label's null terminator and get the mark's offset and duration.
                    m_stream.Position++;
                    uint offset   = m_reader.ReadUInt32();
                    uint duration = m_reader.ReadUInt32();

                    // Increment the byte counter by the number of bytes read for this mark.
                    bytesRead += ((uint)labelLen + 11);

                    string gloss;
                    string reference;
                    bool   isBookMark;
                    if (GetMarkInfo(label, out gloss, out reference, out isBookMark))
                    {
                        m_writer.AddMarkSegment(offset, duration, gloss, null, reference, isBookMark);
                    }
                }
            } catch {
                return(true);
            }

            return(false);
        }