}         // DoEndDocument

        // ----------------------------------------------------------------------
        private void EndParagraph(IRtfInterpreterContext context)
        {
            RtfTextAlignment finalParagraphAlignment = context.GetSafeCurrentTextFormat().Alignment;

            foreach (IRtfVisual alignedVisual in pendingParagraphContent)
            {
                switch (alignedVisual.Kind)
                {
                case RtfVisualKind.Image:
                    RtfVisualImage image = (RtfVisualImage)alignedVisual;
                    // ReSharper disable RedundantCheckBeforeAssignment
                    if (image.Alignment != finalParagraphAlignment)
                    // ReSharper restore RedundantCheckBeforeAssignment
                    {
                        image.Alignment = finalParagraphAlignment;
                    }
                    break;

                case RtfVisualKind.Text:
                    RtfVisualText text = (RtfVisualText)alignedVisual;
                    if (text.Format.Alignment != finalParagraphAlignment)
                    {
                        IRtfTextFormat correctedFormat       = ((RtfTextFormat)text.Format).DeriveWithAlignment(finalParagraphAlignment);
                        IRtfTextFormat correctedUniqueFormat = context.GetUniqueTextFormatInstance(correctedFormat);
                        text.Format = correctedUniqueFormat;
                    }
                    break;
                }
            }
            pendingParagraphContent.Clear();
        }         // EndParagraph
        }         // DoBeginDocument

        // ----------------------------------------------------------------------
        protected override void DoInsertText(IRtfInterpreterContext context, string text)
        {
            if (combineTextWithSameFormat)
            {
                IRtfTextFormat newFormat = context.GetSafeCurrentTextFormat();
                if (!newFormat.Equals(pendingTextFormat))
                {
                    FlushPendingText();
                }
                pendingTextFormat = newFormat;
                pendingText.Append(text);
            }
            else
            {
                AppendAlignedVisual(new RtfVisualText(text, context.GetSafeCurrentTextFormat()));
            }
        }         // DoInsertText
        }         // DoBeginDocument

        // ----------------------------------------------------------------------
        protected override void DoInsertText(IRtfInterpreterContext context, string text)
        {
            if (this.combineTextWithSameFormat)
            {
                IRtfTextFormat newFormat = context.GetSafeCurrentTextFormat();
                if (!newFormat.Equals(this.pendingTextFormat))
                {
                    FlushPendingText();
                }
                this.pendingTextFormat = newFormat;
                this.pendingText.Append(text);
            }
            else
            {
                this.visualContent.Add(new RtfVisualText(text, context.GetSafeCurrentTextFormat()));
            }
        }         // DoInsertText
		} // DoBeginDocument

		// ----------------------------------------------------------------------
		protected override void DoInsertText( IRtfInterpreterContext context, string text )
		{
			if ( this.combineTextWithSameFormat )
			{
				IRtfTextFormat newFormat = context.GetSafeCurrentTextFormat();
				if ( !newFormat.Equals( this.pendingTextFormat ) )
				{
					FlushPendingText();
				}
				this.pendingTextFormat = newFormat;
				this.pendingText.Append( text );
			}
			else
			{
				this.visualContent.Add( new RtfVisualText( text, context.GetSafeCurrentTextFormat() ) );
			}
		} // DoInsertText
        }         // DoInsertBreak

        // ----------------------------------------------------------------------
        protected override void DoInsertImage(IRtfInterpreterContext context,
                                              RtfVisualImageFormat format,
                                              int width, int height, int desiredWidth, int desiredHeight,
                                              int scaleWidthPercent, int scaleHeightPercent,
                                              string imageDataHex, string importFileName
                                              )
        {
            FlushPendingText();
            AppendAlignedVisual(new RtfVisualImage(format,
                                                   context.GetSafeCurrentTextFormat().Alignment,
                                                   width, height, desiredWidth, desiredHeight,
                                                   scaleWidthPercent, scaleHeightPercent, imageDataHex, importFileName));
        }         // DoInsertImage
        }         // DoBeginDocument

        // ----------------------------------------------------------------------
        protected override void DoInsertText(IRtfInterpreterContext context, string text)
        {
            if (settings.Enabled && logger.IsInfoEnabled && !string.IsNullOrEmpty(settings.TextFormatText))
            {
                string msg = text;
                if (msg.Length > settings.TextMaxLength && !string.IsNullOrEmpty(settings.TextOverflowText))
                {
                    msg = msg.Substring(0, msg.Length - settings.TextOverflowText.Length) + settings.TextOverflowText;
                }
                Log(string.Format(
                        CultureInfo.InvariantCulture,
                        settings.TextFormatText,
                        msg,
                        context.GetSafeCurrentTextFormat()));
            }
        }         // DoInsertText
        // ----------------------------------------------------------------------
        protected override void DoInsertImage( IRtfInterpreterContext context,
			RtfVisualImageFormat format,
			int width, int height, int desiredWidth, int desiredHeight,
			int scaleWidthPercent, int scaleHeightPercent,
			string imageDataHex
		)
        {
            FlushPendingText();
            AppendAlignedVisual( new RtfVisualImage( format,
                context.GetSafeCurrentTextFormat().Alignment,
                width, height, desiredWidth, desiredHeight,
                scaleWidthPercent, scaleHeightPercent, imageDataHex ) );
        }
 // ----------------------------------------------------------------------
 private void EndParagraph( IRtfInterpreterContext context )
 {
     RtfTextAlignment finalParagraphAlignment = context.GetSafeCurrentTextFormat().Alignment;
     foreach ( IRtfVisual alignedVisual in pendingParagraphContent )
     {
         switch ( alignedVisual.Kind )
         {
             case RtfVisualKind.Image:
                 RtfVisualImage image = (RtfVisualImage)alignedVisual;
                 // ReSharper disable RedundantCheckBeforeAssignment
                 if ( image.Alignment != finalParagraphAlignment )
                 // ReSharper restore RedundantCheckBeforeAssignment
                 {
                     image.Alignment = finalParagraphAlignment;
                 }
                 break;
             case RtfVisualKind.Text:
                 RtfVisualText text = (RtfVisualText)alignedVisual;
                 if ( text.Format.Alignment != finalParagraphAlignment )
                 {
                     IRtfTextFormat correctedFormat = ( (RtfTextFormat)text.Format ).DeriveWithAlignment( finalParagraphAlignment );
                     IRtfTextFormat correctedUniqueFormat = context.GetUniqueTextFormatInstance( correctedFormat );
                     text.Format = correctedUniqueFormat;
                 }
                 break;
         }
     }
     pendingParagraphContent.Clear();
 }
 // ----------------------------------------------------------------------
 protected override void DoInsertText( IRtfInterpreterContext context, string text )
 {
     if ( combineTextWithSameFormat )
     {
         IRtfTextFormat newFormat = context.GetSafeCurrentTextFormat();
         if ( !newFormat.Equals( pendingTextFormat ) )
         {
             FlushPendingText();
         }
         pendingTextFormat = newFormat;
         pendingText.Append( text );
     }
     else
     {
         AppendAlignedVisual( new RtfVisualText( text, context.GetSafeCurrentTextFormat() ) );
     }
 }
 // ----------------------------------------------------------------------
 protected override void DoInsertText( IRtfInterpreterContext context, string text )
 {
     if ( settings.Enabled && logger.IsInfoEnabled && !string.IsNullOrEmpty( settings.TextFormatText ) )
     {
         string msg = text;
         if ( msg.Length > settings.TextMaxLength && !string.IsNullOrEmpty( settings.TextOverflowText ) )
         {
             msg = msg.Substring( 0, msg.Length - settings.TextOverflowText.Length ) + settings.TextOverflowText;
         }
         Log( string.Format(
             CultureInfo.InvariantCulture,
             settings.TextFormatText,
             msg,
             context.GetSafeCurrentTextFormat() ) );
     }
 }
        }         // DoInsertText

        // ----------------------------------------------------------------------
        protected override void DoInsertSpecialChar(IRtfInterpreterContext context, RtfVisualSpecialCharKind kind)
        {
            FlushPendingText();
            visualDocumentContent.Add(new RtfVisualSpecialChar(kind, context.GetSafeCurrentTextFormat()));
        }         // DoInsertSpecialChar