示例#1
0
        }         // IsSupportedDocument

        // ----------------------------------------------------------------------
        public static IRtfGroup GetSupportedDocument(IRtfGroup rtfDocument)
        {
            if (rtfDocument == null)
            {
                throw new ArgumentNullException("rtfDocument");
            }
            if (rtfDocument.Contents.Count == 0)
            {
                throw new RtfEmptyDocumentException(Strings.EmptyDocument);
            }
            IRtfElement firstElement = rtfDocument.Contents[0];

            if (firstElement.Kind != RtfElementKind.Tag)
            {
                throw new RtfStructureException(Strings.MissingDocumentStartTag);
            }
            IRtfTag firstTag = (IRtfTag)firstElement;

            if (!RtfSpec.TagRtf.Equals(firstTag.Name))
            {
                throw new RtfStructureException(Strings.InvalidDocumentStartTag(RtfSpec.TagRtf));
            }
            if (!firstTag.HasValue)
            {
                throw new RtfUnsupportedStructureException(Strings.MissingRtfVersion);
            }
            if (firstTag.ValueAsNumber != RtfSpec.RtfVersion1)
            {
                throw new RtfUnsupportedStructureException(Strings.UnsupportedRtfVersion(firstTag.ValueAsNumber));
            }
            return(rtfDocument);
        }         // GetSupportedDocument
示例#2
0
        } // CopyTo

        public void Add(IRtfElement item)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }
            InnerList.Add(item);
        } // Add
 // ----------------------------------------------------------------------
 public void Add( IRtfElement item )
 {
     if ( item == null )
     {
         throw new ArgumentNullException( "item" );
     }
     InnerList.Add( item );
 }
 // ----------------------------------------------------------------------
 static void RtfDumpElement( IRtfElement rtfElement )
 {
     switch ( rtfElement.Kind )
     {
         case RtfElementKind.Group:
             Console.WriteLine( "Group: " + ((IRtfGroup)rtfElement).Destination );
             foreach ( IRtfElement rtfChildElement in ((IRtfGroup)rtfElement).Contents )
             {
                 RtfDumpElement( rtfChildElement );
             }
             break;
         case RtfElementKind.Tag:
             Console.WriteLine( "Tag: " + ((IRtfTag)rtfElement).FullName );
             break;
         case RtfElementKind.Text:
             Console.WriteLine( "Text: " + ((IRtfText)rtfElement).Text );
             break;
     }
 }
示例#5
0
        }         // RtfSympleParser

        // ----------------------------------------------------------------------
        static void RtfDumpElement(IRtfElement rtfElement)
        {
            switch (rtfElement.Kind)
            {
            case RtfElementKind.Group:
                Console.WriteLine("Group: " + ((IRtfGroup)rtfElement).Destination);
                foreach (IRtfElement rtfChildElement in ((IRtfGroup)rtfElement).Contents)
                {
                    RtfDumpElement(rtfChildElement);
                }
                break;

            case RtfElementKind.Tag:
                Console.WriteLine("Tag: " + ((IRtfTag)rtfElement).FullName);
                break;

            case RtfElementKind.Text:
                Console.WriteLine("Text: " + ((IRtfText)rtfElement).Text);
                break;
            }
        }         // RtfDumpElement
 // ----------------------------------------------------------------------
 public void CopyTo( IRtfElement[] array, int index )
 {
     InnerList.CopyTo( array, index );
 }