Ejemplo n.º 1
0
 /// <summary>
 /// (non-Javadoc)
 /// @see com.lowagie.text.rtf.direct.RtfDestination#handleGroupEnd()
 /// </summary>
 public override bool HandleCloseGroup()
 {
     if (_text.Length > 0)
     {
         var doc = RtfParser.GetDocument();
         if (doc != null)
         {
             if (_elementName.Equals("author"))
             {
                 doc.AddAuthor(_text);
             }
             if (_elementName.Equals("title"))
             {
                 doc.AddTitle(_text);
             }
             if (_elementName.Equals("subject"))
             {
                 doc.AddSubject(_text);
             }
         }
         else
         {
             var rtfDoc = RtfParser.GetRtfDocument();
             if (rtfDoc != null)
             {
                 if (_elementName.Equals("author"))
                 {
                     var meta = new Meta(_elementName, _text);
                     var elem = new RtfInfoElement(rtfDoc, meta);
                     rtfDoc.GetDocumentHeader().AddInfoElement(elem);
                 }
                 if (_elementName.Equals("title"))
                 {
                     var meta = new Meta(_elementName, _text);
                     var elem = new RtfInfoElement(rtfDoc, meta);
                     rtfDoc.GetDocumentHeader().AddInfoElement(elem);
                 }
                 if (_elementName.Equals("subject"))
                 {
                     var meta = new Meta(_elementName, _text);
                     var elem = new RtfInfoElement(rtfDoc, meta);
                     rtfDoc.GetDocumentHeader().AddInfoElement(elem);
                 }
             }
         }
         SetToDefaults();
     }
     return(true);
 }
 /* (non-Javadoc)
  * @see com.lowagie.text.rtf.direct.RtfDestination#handleGroupEnd()
  */
 public override bool HandleCloseGroup()
 {
     if (this.text.Length > 0)
     {
         Document doc = this.rtfParser.GetDocument();
         if (doc != null)
         {
             if (this.elementName.Equals("author"))
             {
                 doc.AddAuthor(this.text);
             }
             if (this.elementName.Equals("title"))
             {
                 doc.AddTitle(this.text);
             }
             if (this.elementName.Equals("subject"))
             {
                 doc.AddSubject(this.text);
             }
         }
         else
         {
             RtfDocument rtfDoc = this.rtfParser.GetRtfDocument();
             if (rtfDoc != null)
             {
                 if (this.elementName.Equals("author"))
                 {
                     Meta           meta = new Meta(this.elementName, this.text);
                     RtfInfoElement elem = new RtfInfoElement(rtfDoc, meta);
                     rtfDoc.GetDocumentHeader().AddInfoElement(elem);
                 }
                 if (this.elementName.Equals("title"))
                 {
                     Meta           meta = new Meta(this.elementName, this.text);
                     RtfInfoElement elem = new RtfInfoElement(rtfDoc, meta);
                     rtfDoc.GetDocumentHeader().AddInfoElement(elem);
                 }
                 if (this.elementName.Equals("subject"))
                 {
                     Meta           meta = new Meta(this.elementName, this.text);
                     RtfInfoElement elem = new RtfInfoElement(rtfDoc, meta);
                     rtfDoc.GetDocumentHeader().AddInfoElement(elem);
                 }
             }
         }
         this.SetToDefaults();
     }
     return(true);
 }
Ejemplo n.º 3
0
        /**
         * Takes an Element subclass and returns the correct IRtfBasicElement
         * subclass, that wraps the Element subclass.
         *
         * @param element The Element to wrap
         * @return A IRtfBasicElement wrapping the Element
         * @throws DocumentException
         */
        public IRtfBasicElement MapElement(IElement element)
        {
            IRtfBasicElement rtfElement = null;

            if (element is IRtfBasicElement)
            {
                rtfElement = (IRtfBasicElement)element;
                rtfElement.SetRtfDocument(this.rtfDoc);
                return(rtfElement);
            }
            switch (element.Type)
            {
            case Element.CHUNK:
                if (((Chunk)element).GetImage() != null)
                {
                    rtfElement = new RtfImage(rtfDoc, ((Chunk)element).GetImage());
                }
                else if (((Chunk)element).HasAttributes() && ((Chunk)element).Attributes.ContainsKey(Chunk.NEWPAGE))
                {
                    rtfElement = new RtfNewPage(rtfDoc);
                }
                else
                {
                    rtfElement = new RtfChunk(rtfDoc, (Chunk)element);
                }
                break;

            case Element.PHRASE:
                rtfElement = new RtfPhrase(rtfDoc, (Phrase)element);
                break;

            case Element.PARAGRAPH:
                rtfElement = new RtfParagraph(rtfDoc, (Paragraph)element);
                break;

            case Element.ANCHOR:
                rtfElement = new RtfAnchor(rtfDoc, (Anchor)element);
                break;

            case Element.ANNOTATION:
                rtfElement = new RtfAnnotation(rtfDoc, (Annotation)element);
                break;

            case Element.IMGRAW:
            case Element.IMGTEMPLATE:
            case Element.JPEG:
                rtfElement = new RtfImage(rtfDoc, (Image)element);
                break;

            case Element.AUTHOR:
            case Element.SUBJECT:
            case Element.KEYWORDS:
            case Element.TITLE:
            case Element.PRODUCER:
            case Element.CREATIONDATE:
                rtfElement = new RtfInfoElement(rtfDoc, (Meta)element);
                break;

            case Element.LIST:
                rtfElement = new RtfList(rtfDoc, (List)element);
                break;

            case Element.LISTITEM:
                rtfElement = new RtfListItem(rtfDoc, (ListItem)element);
                break;

            case Element.SECTION:
                rtfElement = new RtfSection(rtfDoc, (Section)element);
                break;

            case Element.CHAPTER:
                rtfElement = new RtfChapter(rtfDoc, (Chapter)element);
                break;

            case Element.TABLE:
                try {
                    rtfElement = new TB.RtfTable(rtfDoc, (Table)element);
                }
                catch (InvalidCastException) {
                    rtfElement = new TB.RtfTable(rtfDoc, ((SimpleTable)element).CreateTable());
                }
                break;
            }

            return(rtfElement);
        }