override public void AfterParentSet()
        {
            ClientTextbox textbox = this.ParentRecord as ClientTextbox;

            if (textbox == null)
            {
                TraceLogger.DebugInternal("Record of type StyleTextPropAtom doesn't have parent of type ClientTextbox: {0}", this);
                return;
            }

            // TODO: FindSiblingByType?
            TextAtom textAtom = textbox.FirstChildWithType <TextAtom>();

            /* This can legitimately happen... */
            if (textAtom == null)
            {
                this.Reader.Read(new char[this.BodySize], 0, (int)this.BodySize);
                return;
            }

            // TODO: Length in bytes? UTF-16 characters? Full width unicode characters?

            //TraceLogger.DebugInternal("New text style for text: {0}", Utils.StringInspect(textAtom.Text));

            uint seenLength = 0;

            while (seenLength < textAtom.Text.Length + 1)
            {
                long pos    = this.Reader.BaseStream.Position;
                uint length = this.Reader.ReadUInt32();

                ParagraphRun run = new ParagraphRun(this.Reader, false);
                run.Length = length;
                this.PRuns.Add(run);

                /*TraceLogger.DebugInternal("Read paragraph run. Before pos = {0}, after pos = {1} of {2}: {3}",
                 *  pos, this.Reader.BaseStream.Position, this.Reader.BaseStream.Length,
                 *  run);*/

                seenLength += length;
            }

            //TraceLogger.DebugInternal();

            seenLength = 0;
            while (seenLength < textAtom.Text.Length + 1)
            {
                uint length = this.Reader.ReadUInt32();

                CharacterRun run = new CharacterRun(this.Reader);
                run.Length = length;
                this.CRuns.Add(run);

                seenLength += length;
            }
        }
        override public void AfterTextHeaderSet()
        {
            TextAtom textAtom = this.TextHeaderAtom.TextAtom;

            /* This can legitimately happen... */
            if (textAtom == null)
            {
                this.Reader.BaseStream.Position = this.Reader.BaseStream.Length;
                return;
            }

            uint seenLength = 0;

            while (seenLength < textAtom.Text.Length + 1)
            {
                long pos    = this.Reader.BaseStream.Position;
                uint length = this.Reader.ReadUInt32();

                ParagraphRun run = new ParagraphRun(this.Reader, false);
                run.Length = length;
                this.PRuns.Add(run);

                /*TraceLogger.DebugInternal("Read paragraph run. Before pos = {0}, after pos = {1} of {2}: {3}",
                 *  pos, this.Reader.BaseStream.Position, this.Reader.BaseStream.Length,
                 *  run);*/

                seenLength += length;
            }

            //TraceLogger.DebugInternal();

            seenLength = 0;
            while (seenLength < textAtom.Text.Length + 1)
            {
                uint length = this.Reader.ReadUInt32();

                CharacterRun run = new CharacterRun(this.Reader);
                run.Length = length;
                this.CRuns.Add(run);

                seenLength += length;
            }

            this.VerifyReadToEnd();
        }
        public void HandleTextDataRecord(ITextDataRecord tdRecord)
        {
            tdRecord.TextHeaderAtom = this;

            TextAtom      textAtom = tdRecord as TextAtom;
            TextStyleAtom tsAtom   = tdRecord as TextStyleAtom;

            if (textAtom != null)
            {
                this.TextAtom = textAtom;
            }
            else if (tsAtom != null)
            {
                this.TextStyleAtom = tsAtom;
            }
            else
            {
                throw new NotImplementedException("Unhandled text data record type " + tdRecord.GetType().ToString());
            }
        }