示例#1
0
        public void AddChild(PowerPointRecord entry)
        {
            if (this._children == null)
            {
                this._children = new List <PowerPointRecord>();
            }

            this._children.Add(entry);
        }
示例#2
0
        /// <summary>
        /// 初始化新的Record
        /// </summary>
        /// <param name="parent">父节点</param>
        /// <param name="version">RecordVersion和Instance</param>
        /// <param name="type">Record类型</param>
        /// <param name="length">Record内容大小</param>
        /// <param name="offset">Record相对PowerPoint Document偏移</param>
        public PowerPointRecord(PowerPointRecord parent, UInt16 version, UInt16 type, UInt32 length, Int64 offset)
        {
            this._recVer      = (UInt16)(version & 0xF);
            this._recInstance = (UInt16)(version & 0xFFF0);
            this._recType     = (RecordType)type;
            this._recLen      = length;
            this._offset      = offset;
            this._deepth      = (parent == null ? 0 : parent._deepth + 1);
            this._parent      = parent;

            if (_recVer == 0xF)
            {
                this._children = new List <PowerPointRecord>();
            }
        }
        /// <summary>
        /// 初始化新的Record
        /// </summary>
        /// <param name="parent">父节点</param>
        /// <param name="version">RecordVersion和Instance</param>
        /// <param name="type">Record类型</param>
        /// <param name="length">Record内容大小</param>
        /// <param name="offset">Record相对PowerPoint Document偏移</param>
        public PowerPointRecord(PowerPointRecord parent, UInt16 version, UInt16 type, UInt32 length, Int64 offset)
        {
            this._recVer = (UInt16)(version & 0xF);
            this._recInstance = (UInt16)(version & 0xFFF0);
            this._recType = (RecordType)type;
            this._recLen = length;
            this._offset = offset;
            this._deepth = (parent == null ? 0 : parent._deepth + 1);
            this._parent = parent;

            if (_recVer == 0xF)
            {
                this._children = new List<PowerPointRecord>();
            }
        }
        public void AddChild(PowerPointRecord entry)
        {
            if (this._children == null)
            {
                this._children = new List<PowerPointRecord>();
            }

            this._children.Add(entry);
        }
        private PowerPointRecord GetRecord(PowerPointRecord parent)
        {
            if (this._stream.Position >= this._stream.Length)
            {
                return null;
            }

            UInt16 version = this._reader.ReadUInt16();
            UInt16 type = this._reader.ReadUInt16();
            UInt32 length = this._reader.ReadUInt32();

            return new PowerPointRecord(parent, version, type, length, this._stream.Position);
        }
        private PowerPointRecord ReadRecord(PowerPointRecord parent)
        {
            PowerPointRecord record = GetRecord(parent);

            if (record == null)
            {
                return null;
            }
            #region 测试方法
            else
            {
                this._recordTree.Append('-', record.Deepth * 2);
                this._recordTree.AppendFormat("[{0}]-[{1}]-[Len:{2}]", record.RecordType, record.Deepth, record.RecordLength);
                this._recordTree.AppendLine();
            }
            #endregion

            if (parent == null)
            {
                this._records.Add(record);
            }
            else
            {
                parent.AddChild(record);
            }

            if (record.RecordVersion == 0xF)
            {
                while (this._stream.Position < record.Offset + record.RecordLength)
                {
                    this.ReadRecord(record);
                }
            }
            else
            {
                if (record.Parent != null && (
                    record.Parent.RecordType == RecordType.ListWithTextContainer ||
                    record.Parent.RecordType == RecordType.HeadersFootersContainer ||
                    (UInt32)record.Parent.RecordType == 0xF00D))
                {
                    if (record.RecordType == RecordType.TextCharsAtom || record.RecordType == RecordType.CString)//找到Unicode双字节文字内容
                    {
                        Byte[] data = this._reader.ReadBytes((Int32)record.RecordLength);
                        this._allText.Append(StringHelper.GetString(true, data));
                        this._allText.AppendLine();

                    }
                    else if (record.RecordType == RecordType.TextBytesAtom)//找到Unicode<256单字节文字内容
                    {
                        Byte[] data = this._reader.ReadBytes((Int32)record.RecordLength);
                        this._allText.Append(StringHelper.GetString(false, data));
                        this._allText.AppendLine();
                    }
                    else
                    {
                        this._stream.Seek(record.RecordLength, SeekOrigin.Current);
                    }
                }
                else
                {
                    this._stream.Seek(record.RecordLength, SeekOrigin.Current);
                }
            }

            return record;
        }