Inheritance: iTextSharp.text.rtf.RtfElement
Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
 /**
  * Constructs a RtfRow for a Row.
  *
  * @param doc The RtfDocument this RtfRow belongs to
  * @param rtfTable The RtfTable this RtfRow belongs to
  * @param row The Row this RtfRow is based on
  * @param rowNumber The number of this row
  */
 protected internal RtfRow(RtfDocument doc, RtfTable rtfTable, Row row, int rowNumber) : base(doc)
 {
     this.parentTable = rtfTable;
     this.rowNumber   = rowNumber;
     ImportRow(row);
 }
 /// <summary>
 /// Constructs a RtfRow for a Row.
 /// @since 2.1.3
 /// </summary>
 /// <param name="doc">The RtfDocument this RtfRow belongs to</param>
 /// <param name="rtfTable">The RtfTable this RtfRow belongs to</param>
 /// <param name="row">The Row this RtfRow is based on</param>
 /// <param name="rowNumber">The number of this row</param>
 protected internal RtfRow(RtfDocument doc, RtfTable rtfTable, PdfPRow row, int rowNumber) : base(doc)
 {
     _parentTable = rtfTable;
     _rowNumber   = rowNumber;
     importRow(row);
 }
Exemplo n.º 4
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;
        }