Inheritance: RtfInterpreterListenerBase
 // ----------------------------------------------------------------------
 public static IRtfDocument BuildDoc( IRtfGroup rtfDocument, params IRtfInterpreterListener[] listeners )
 {
     RtfInterpreterListenerDocumentBuilder docBuilder = new RtfInterpreterListenerDocumentBuilder();
     IRtfInterpreterListener[] allListeners;
     if ( listeners == null )
     {
         allListeners = new IRtfInterpreterListener[] { docBuilder };
     }
     else
     {
         allListeners = new IRtfInterpreterListener[ listeners.Length + 1 ];
         allListeners[ 0 ] = docBuilder;
         listeners.CopyTo( allListeners, 1 );
     }
     Interpret( rtfDocument, allListeners );
     return docBuilder.Document;
 }
        public void DocumentBuilderTest()
        {
            const RtfParserListenerLogger parserLogger = null;
            //parserLogger = new RtfParserListenerLogger();
            IRtfGroup rtfStructure =
                RtfParserTool.Parse( GetTestResource( "RtfInterpreterTest_1.rtf" ), parserLogger );
            Assert.IsNotNull( rtfStructure );

            const RtfInterpreterListenerLogger interpreterLogger = null;
            //interpreterLogger = new RtfInterpreterListenerLogger();

            RtfInterpreterListenerDocumentBuilder docBuilder =
                new RtfInterpreterListenerDocumentBuilder();

            RtfInterpreterTool.Interpret( rtfStructure, docBuilder, interpreterLogger );
            IRtfDocument doc = docBuilder.Document;
            Assert.IsNotNull( doc );

            Assert.AreEqual( "TX_RTF32 14.0.520.501", doc.Generator );

            Assert.AreEqual( 3, doc.FontTable.Count );
            Assert.AreEqual( RtfFontKind.Swiss, doc.FontTable[ 0 ].Kind );
            Assert.AreEqual( RtfFontPitch.Variable, doc.FontTable[ 0 ].Pitch );
            Assert.AreEqual( 0, doc.FontTable[ 0 ].CharSet );
            Assert.AreEqual( 1252, doc.FontTable[ 0 ].CodePage );
            Assert.AreEqual( "Arial", doc.FontTable[ 0 ].Name );

            Assert.AreEqual( RtfFontKind.Swiss, doc.FontTable[ 1 ].Kind );
            Assert.AreEqual( RtfFontPitch.Variable, doc.FontTable[ 1 ].Pitch );
            Assert.AreEqual( 0, doc.FontTable[ 01 ].CharSet );
            Assert.AreEqual( 1252, doc.FontTable[ 1 ].CodePage );
            Assert.AreEqual( "Verdana", doc.FontTable[ 1 ].Name );

            Assert.AreEqual( RtfFontKind.Roman, doc.FontTable[ 2 ].Kind );
            Assert.AreEqual( RtfFontPitch.Variable, doc.FontTable[ 2 ].Pitch );
            Assert.AreEqual( 2, doc.FontTable[ 2 ].CharSet );
            Assert.AreEqual( 42, doc.FontTable[ 2 ].CodePage );
            Assert.AreEqual( "Symbol", doc.FontTable[ 2 ].Name );

            Assert.AreSame( doc.DefaultFont, doc.FontTable[ 1 ] );

            Assert.AreEqual( 4, doc.ColorTable.Count );
            Assert.AreEqual( RtfColor.Black, doc.ColorTable[ 0 ] );
            Assert.AreEqual( RtfColor.Black, doc.ColorTable[ 1 ] );
            Assert.AreEqual( RtfColor.White, doc.ColorTable[ 2 ] );
            Assert.AreEqual( new RtfColor( 10, 20, 30 ), doc.ColorTable[ 3 ] );

            Assert.AreEqual( 2, doc.VisualContent.Count );
            Assert.AreEqual( RtfVisualKind.Text, doc.VisualContent[ 0 ].Kind );
            Assert.AreEqual( "Hellou RTF Wörld", ((IRtfVisualText)doc.VisualContent[ 0 ]).Text );
            Assert.AreEqual( "Verdana", ((IRtfVisualText)doc.VisualContent[ 0 ]).Format.Font.Name );
            Assert.AreEqual( 36, ((IRtfVisualText)doc.VisualContent[ 0 ]).Format.FontSize );
            Assert.AreEqual( RtfVisualKind.Break, doc.VisualContent[ 1 ].Kind );
            Assert.AreEqual( RtfVisualBreakKind.Paragraph, ((IRtfVisualBreak)doc.VisualContent[ 1 ]).BreakKind );

            Assert.AreEqual( 5, doc.UserProperties.Count );
            Assert.AreEqual( "created", doc.UserProperties[ 0 ].Name );
            Assert.AreEqual( RtfPropertyKind.Date, doc.UserProperties[ 0 ].PropertyKind );
            Assert.AreEqual( "2008-05-23", doc.UserProperties[ 0 ].StaticValue );
            Assert.IsNull( doc.UserProperties[ 0 ].LinkValue );
            Assert.AreEqual( "a link", doc.UserProperties[ 4 ].LinkValue );

            IRtfDocumentInfo info = doc.DocumentInfo;
            Assert.AreEqual( 2, info.Version );
            Assert.AreEqual( 3, info.Revision );
            Assert.AreEqual( 1, info.NumberOfPages );
            Assert.AreEqual( 3, info.NumberOfWords );
            Assert.AreEqual( 16, info.NumberOfCharacters );
            Assert.AreEqual( 314, info.Id );
            Assert.AreEqual( 17, info.EditingTimeInMinutes );
            Assert.AreEqual( "Not really important", info.Title );
            Assert.AreEqual( "RTF parsing", info.Subject );
            Assert.AreEqual( "John Doe", info.Author );
            Assert.AreEqual( "John Doe's boss", info.Manager );
            Assert.AreEqual( "Itenso GmbH", info.Company );
            Assert.AreEqual( "Foo Bar", info.Operator );
            Assert.AreEqual( "Development", info.Category );
            Assert.AreEqual( "RTF, Parser, Interpreter", info.Keywords );
            Assert.AreEqual( "a testing document", info.Comment );
            Assert.AreEqual( "with more commentary", info.DocumentComment );
            Assert.AreEqual( "http://wwww.nowhere.com/foo/bar", info.HyperLinkbase );
            Assert.AreEqual( Time( "2008.05.23-17:55:12" ), info.CreationTime );
            Assert.AreEqual( Time( "2008.05.23-18:01:00" ), info.RevisionTime );
            Assert.AreEqual( Time( "2008.05.23-17:59:00" ), info.PrintTime );
            Assert.AreEqual( Time( "2008.05.23-18:00:00" ), info.BackupTime );
        }
        // ----------------------------------------------------------------------
        protected override void DoTest( string kind, Stream testRes, string testCaseName )
        {
            const RtfParserListenerLogger parserLogger = null;
            //parserLogger = new RtfParserListenerLogger();

            const RtfInterpreterListenerLogger interpreterLogger = null;
            //interpreterLogger = new RtfInterpreterListenerLogger();

            RtfTextConverter textConverter = new RtfTextConverter();

            RtfInterpreterListenerDocumentBuilder docBuilder =
                new RtfInterpreterListenerDocumentBuilder();

            RtfInterpreterTool.Interpret( RtfParserTool.Parse( testRes, parserLogger ),
                interpreterLogger, textConverter, docBuilder );

            string plainText = textConverter.PlainText;
            Assert.IsFalse( string.IsNullOrEmpty( plainText ) );
            Assert.IsNotNull( docBuilder.Document );

            string testName = testCaseName.Substring( 0, testCaseName.Length - 4 );
            //string unicode = "バージョンアップ注文書(銀行振込)";
            Encoding enc;
            switch ( testName )
            {
                case "RtfInterpreterTest_12":
                case "RtfInterpreterTest_13":
                case "RtfInterpreterTest_14":
                case "RtfInterpreterTest_16":
                case "RtfInterpreterTest_17":
                case "RtfInterpreterTest_18":
                case "RtfInterpreterTest_19":
                case "RtfInterpreterTest_21":
                    enc = Encoding.Unicode;
                    break;
                default:
                    enc = RtfSpec.AnsiEncoding;
                    break;
            }
            string referenceResName = testName + ".txt";
            /*
            if ( "RtfInterpreterTest_21".Equals( testName ) )
            {
                using ( Stream s = new FileStream( @"w:\temp\rtf\RtfInterpreterTest_21.txt", FileMode.Create ) )
                {
                    using ( TextWriter w = new StreamWriter( s, enc ) )
                    {
                        w.Write( plainText );
                    }
                }
            }
            //*/
            if ( plainText == null )
            {
                plainText = string.Empty;
            }
            AssertEqualLines( "document recognition: " + testCaseName + ":",
                new StreamReader( GetTestResource( referenceResName ), enc ),
                new StringReader( plainText ) );
        }