/// <summary>
        ///   Renders the paragraph content to RTF.
        /// </summary>
        private void RenderContent()
        {
            DocumentElements elements = DocumentRelations.GetParent(_paragraph) as DocumentElements;

            //First paragraph of a footnote writes the reference symbol:
            if (DocumentRelations.GetParent(elements) is Footnote && _paragraph == elements.First)
            {
                FootnoteRenderer ftntRenderer = new FootnoteRenderer(DocumentRelations.GetParent(elements) as Footnote,
                                                                     _docRenderer);
                ftntRenderer.RenderReference();
            }
            foreach (DocumentObject docObj in _paragraph.Elements)
            {
                if (docObj == _paragraph.Elements.LastObject)
                {
                    if (docObj is Character)
                    {
                        if (((Character)docObj).SymbolName == SymbolName.LineBreak)
                        {
                            continue; //Ignore last linebreak.
                        }
                    }
                }
                RendererBase rndrr = RendererFactory.CreateRenderer(docObj, _docRenderer);
                if (rndrr != null)
                {
                    rndrr.Render();
                }
            }
        }
        internal override void Render()
        {
            _rtfWriter.StartContent();
            int          currIdx = _styles.GetIndex(_style.Name);
            RendererBase rndrr   = null;

            if (_style.Type == StyleType.Character)
            {
                _rtfWriter.WriteControlWithStar("cs", currIdx);
                _rtfWriter.WriteControl("additive");
                rndrr = RendererFactory.CreateRenderer(_style.Font, _docRenderer);
            }
            else
            {
                _rtfWriter.WriteControl("s", currIdx);
                rndrr = RendererFactory.CreateRenderer(_style.ParagraphFormat, _docRenderer);
            }
            if (_style.BaseStyle != "")
            {
                int bsIdx = _styles.GetIndex(_style.BaseStyle);
                _rtfWriter.WriteControl("sbasedon", bsIdx);
            }
            rndrr.Render();
            _rtfWriter.WriteText(_style.Name);
            _rtfWriter.WriteSeparator();
            _rtfWriter.EndContent();
        }
 /// <summary>
 /// Renders a TabStops collection to RTF.
 /// </summary>
 internal override void Render()
 {
     foreach (TabStop tabStop in _tabStops)
     {
         RendererFactory.CreateRenderer(tabStop, _docRenderer).Render();
     }
 }
        /// <summary>
        /// Renders a TextFrame to RTF.
        /// </summary>
        internal override void Render()
        {
            DocumentElements elms = DocumentRelations.GetParent(_textFrame) as DocumentElements;
            bool             renderInParagraph = RenderInParagraph();

            if (renderInParagraph)
            {
                StartDummyParagraph();
            }

            StartShapeArea();

            //Properties
            RenderNameValuePair("shapeType", "202");//202 entspr. Textrahmen.

            TranslateAsNameValuePair("MarginLeft", "dxTextLeft", RtfUnit.EMU, "0");
            TranslateAsNameValuePair("MarginTop", "dyTextTop", RtfUnit.EMU, "0");
            TranslateAsNameValuePair("MarginRight", "dxTextRight", RtfUnit.EMU, "0");
            TranslateAsNameValuePair("MarginBottom", "dyTextBottom", RtfUnit.EMU, "0");

            if (_textFrame.IsNull("Elements") ||
                !CollectionContainsObjectAssignableTo(_textFrame.Elements,
                                                      typeof(Shape), typeof(Table)))
            {
                TranslateAsNameValuePair("Orientation", "txflTextFlow", RtfUnit.Undefined, null);
            }
            else
            {
                TextOrientation orient = _textFrame.Orientation;
                if (orient != TextOrientation.Horizontal && orient != TextOrientation.HorizontalRotatedFarEast)
                {
                    Debug.WriteLine(Messages2.TextframeContentsNotTurned, "warning");
                }
            }
            _rtfWriter.StartContent();
            _rtfWriter.WriteControl("shptxt");
            _rtfWriter.StartContent();
            foreach (DocumentObject docObj in _textFrame.Elements)
            {
                RendererBase rndrr = RendererFactory.CreateRenderer(docObj, _docRenderer);
                if (rndrr != null)
                {
                    rndrr.Render();
                }
            }
            //Text fields need to close with a paragraph.
            RenderTrailingParagraph(_textFrame.Elements);

            _rtfWriter.EndContent();
            _rtfWriter.EndContent();
            EndShapeArea();
            if (renderInParagraph)
            {
                RenderLayoutPicture();
                EndDummyParagraph();
            }
        }
 /// <summary>
 /// Renders the RTF document area, which is all except the header.
 /// </summary>
 private void RenderDocumentArea()
 {
     RenderInfo();
     RenderDocumentFormat();
     RenderGlobalPorperties();
     foreach (Section sect in this.document.Sections)
     {
         RendererFactory.CreateRenderer(sect, this).Render();
     }
 }
 /// <summary>
 /// Renders styles as part of the RTF header.
 /// </summary>
 private void RenderStyles()
 {
     rtfWriter.StartContent();
     rtfWriter.WriteControl("stylesheet");
     foreach (Style style in this.document.Styles)
     {
         RendererFactory.CreateRenderer(style, this).Render();
     }
     rtfWriter.EndContent();
 }
Example #7
0
        /// <summary>
        /// Renders a section to RTF
        /// </summary>
        internal override void Render()
        {
            _useEffectiveValue = true;

            Sections secs = DocumentRelations.GetParent(_section) as Sections;

            if (_section != secs.First)
            {
                _rtfWriter.WriteControl("pard");
                _rtfWriter.WriteControl("sect");
            }
            _rtfWriter.WriteControl("sectd");

            //Rendering some footnote attributes:
            _docRenderer.RenderSectionProperties();

            object pageStp = _section.PageSetup;

            if (pageStp != null)
            {
                RendererFactory.CreateRenderer((PageSetup)pageStp, _docRenderer).Render();
            }

            object hdrs = GetValueAsIntended("Headers");

            if (hdrs != null)
            {
                HeadersFootersRenderer hfr = new HeadersFootersRenderer(hdrs as HeadersFooters, _docRenderer);
                // PageSetup has to be set here, because HeaderFooter could be from a different section than PageSetup.
                hfr.PageSetup = (PageSetup)pageStp;
                hfr.Render();
            }

            object ftrs = GetValueAsIntended("Footers");

            if (ftrs != null)
            {
                HeadersFootersRenderer hfr = new HeadersFootersRenderer(ftrs as HeadersFooters, _docRenderer);
                hfr.PageSetup = (PageSetup)pageStp;
                hfr.Render();
            }

            if (!_section.IsNull("Elements"))
            {
                foreach (DocumentObject docObj in _section.Elements)
                {
                    RendererBase rndrr = RendererFactory.CreateRenderer(docObj, _docRenderer);
                    if (rndrr != null)
                    {
                        rndrr.Render();
                    }
                }
            }
        }
Example #8
0
        /// <summary>
        /// Renders a section to RTF
        /// </summary>
        internal override void Render()
        {
            this.useEffectiveValue = true;

            Sections secs = DocumentRelations.GetParent(this.section) as Sections;

            if (this.section != secs.First)
            {
                this.rtfWriter.WriteControl("pard");
                this.rtfWriter.WriteControl("sect");
            }
            this.rtfWriter.WriteControl("sectd");

            //Rendering some footnote attributes:
            this.docRenderer.RenderSectionProperties();

            object pageStp = this.section.PageSetup;

            if (pageStp != null)
            {
                RendererFactory.CreateRenderer((PageSetup)pageStp, this.docRenderer).Render();
            }

            object hdrs = GetValueAsIntended("Headers");

            if (hdrs != null)
            {
                HeadersFootersRenderer hfr = new HeadersFootersRenderer(hdrs as HeadersFooters, this.docRenderer);
                //PageSetup muss hier gesetzt werden, da die HeaderFooter anderem Abschnitt gehören können als das PageSetup
                hfr.PageSetup = (PageSetup)pageStp;
                hfr.Render();
            }

            object ftrs = GetValueAsIntended("Footers");

            if (ftrs != null)
            {
                HeadersFootersRenderer hfr = new HeadersFootersRenderer(ftrs as HeadersFooters, this.docRenderer);
                hfr.PageSetup = (PageSetup)pageStp;
                hfr.Render();
            }

            if (!section.IsNull("Elements"))
            {
                foreach (DocumentObject docObj in this.section.Elements)
                {
                    RendererBase rndrr = RendererFactory.CreateRenderer(docObj, this.docRenderer);
                    if (rndrr != null)
                    {
                        rndrr.Render();
                    }
                }
            }
        }
        /// <summary>
        /// Renders a formatted text to RTF.
        /// </summary>
        internal override void Render()
        {
            _useEffectiveValue = true;

            _rtfWriter.StartContent();
            RenderStyleAndFont();
            foreach (DocumentObject docObj in _formattedText.Elements)
            {
                RendererFactory.CreateRenderer(docObj, _docRenderer).Render();
            }

            _rtfWriter.EndContent();
        }
Example #10
0
 /// <summary>
 /// Renders the footnote's content.
 /// </summary>
 private void RenderContent()
 {
     _rtfWriter.StartContent();
     _rtfWriter.WriteControl("footnote");
     foreach (DocumentObject obj in _footnote.Elements)
     {
         RendererBase rndrr = RendererFactory.CreateRenderer(obj, _docRenderer);
         if (rndrr != null)
         {
             rndrr.Render();
         }
     }
     _rtfWriter.EndContent();
 }
Example #11
0
        /// <summary>
        ///   Renders a hyperlink to RTF.
        /// </summary>
        internal override void Render()
        {
            _useEffectiveValue = true;
            _rtfWriter.StartContent();
            _rtfWriter.WriteControl("field");
            _rtfWriter.StartContent();
            _rtfWriter.WriteControl("fldinst", true);
            _rtfWriter.WriteText("HYPERLINK ");
            string name = _hyperlink.Filename;

            if (_hyperlink.IsNull("Type") || _hyperlink.Type == HyperlinkType.Local)
            {
                name = BookmarkFieldRenderer.MakeValidBookmarkName(_hyperlink.BookmarkName);
                _rtfWriter.WriteText(@"\l ");
            }
            else if (_hyperlink.Type == HyperlinkType.File || _hyperlink.Type == HyperlinkType.ExternalBookmark) // Open at least the document for external bookmarks (in PDF: Links to external named destinations).
            {
                string workingDirectory = _docRenderer.WorkingDirectory;
                if (workingDirectory != null)
                {
                    name = Path.Combine(_docRenderer.WorkingDirectory, name);
                }

                name = name.Replace(@"\", @"\\");
            }

            _rtfWriter.WriteText("\"" + name + "\"");
            _rtfWriter.EndContent();
            _rtfWriter.StartContent();
            _rtfWriter.WriteControl("fldrslt");
            _rtfWriter.StartContent();
            _rtfWriter.WriteControl("cs", _docRenderer.GetStyleIndex("Hyperlink"));

            FontRenderer fontRenderer = new FontRenderer(_hyperlink.Font, _docRenderer);

            fontRenderer.Render();

            if (!_hyperlink.IsNull("Elements"))
            {
                foreach (DocumentObject domObj in _hyperlink.Elements)
                {
                    RendererFactory.CreateRenderer(domObj, _docRenderer).Render();
                }
            }
            _rtfWriter.EndContent();
            _rtfWriter.EndContent();
            _rtfWriter.EndContent();
        }
Example #12
0
        /// <summary>
        /// Renders a hyperlink to RTF.
        /// </summary>
        internal override void Render()
        {
            useEffectiveValue = true;
            this.rtfWriter.StartContent();
            this.rtfWriter.WriteControl("field");
            this.rtfWriter.StartContent();
            this.rtfWriter.WriteControl("fldinst", true);
            this.rtfWriter.WriteText("HYPERLINK ");
            string name = this.hyperlink.Name;

            if (this.hyperlink.IsNull("Type") || this.hyperlink.Type == HyperlinkType.Local)
            {
                name = BookmarkFieldRenderer.MakeValidBookmarkName(this.hyperlink.Name);
                this.rtfWriter.WriteText(@"\l ");
            }
            else if (this.hyperlink.Type == HyperlinkType.File)
            {
                string workingDirectory = this.docRenderer.WorkingDirectory;
                if (workingDirectory != null)
                {
                    name = Path.Combine(this.docRenderer.WorkingDirectory, name);
                }

                name = name.Replace(@"\", @"\\");
            }

            this.rtfWriter.WriteText("\"" + name + "\"");
            this.rtfWriter.EndContent();
            this.rtfWriter.StartContent();
            this.rtfWriter.WriteControl("fldrslt");
            this.rtfWriter.StartContent();
            this.rtfWriter.WriteControl("cs", this.docRenderer.GetStyleIndex("Hyperlink"));

            FontRenderer fontRenderer = new FontRenderer(this.hyperlink.Font, this.docRenderer);

            fontRenderer.Render();

            if (!this.hyperlink.IsNull("Elements"))
            {
                foreach (DocumentObject domObj in hyperlink.Elements)
                {
                    RendererFactory.CreateRenderer(domObj, this.docRenderer).Render();
                }
            }
            this.rtfWriter.EndContent();
            this.rtfWriter.EndContent();
            this.rtfWriter.EndContent();
        }
        /// <summary>
        /// Renders a single Header or Footer.
        /// </summary>
        internal override void Render()
        {
            StringCollection hdrFtrCtrls = GetHeaderFooterControls();

            foreach (string hdrFtrCtrl in hdrFtrCtrls)
            {
                this.rtfWriter.StartContent();
                this.rtfWriter.WriteControl(hdrFtrCtrl);
                //REM: Could be optimized by storing rendering results in a strings.
                foreach (DocumentObject docObj in this.headerFooter.Elements)
                {
                    RendererBase rndrr = RendererFactory.CreateRenderer(docObj, this.docRenderer);
                    if (rndrr != null)
                    {
                        rndrr.Render();
                    }
                }
                this.rtfWriter.EndContent();
            }
        }
Example #14
0
        /// <summary>
        /// Renders format and style. Always call EndFormatAndStyleAfterContent() after the content was written.
        /// </summary>
        protected void RenderStyleAndFormat()
        {
            object styleName    = GetValueAsIntended("Style");
            object parStyleName = styleName;
            Style  style        = _docRenderer.Document.Styles[(string)styleName];

            _hasCharacterStyle = false;
            if (style != null)
            {
                if (style.Type == StyleType.Character)
                {
                    _hasCharacterStyle = true;
                    parStyleName       = "Normal";
                }
            }
            else
            {
                parStyleName = null;
            }

            if (parStyleName != null)
            {
                _rtfWriter.WriteControl("s", _docRenderer.GetStyleIndex((string)parStyleName));
            }

            ParagraphFormat frmt = GetValueAsIntended("Format") as ParagraphFormat;

            RendererFactory.CreateRenderer(frmt, _docRenderer).Render();
            _rtfWriter.WriteControl("brdrbtw");// Should separate border, but does not work.
            if (_hasCharacterStyle)
            {
                _rtfWriter.StartContent();
                _rtfWriter.WriteControlWithStar("cs", _docRenderer.GetStyleIndex((string)styleName));
                object font = GetValueAsIntended("Format.Font");
                if (font != null)
                {
                    new FontRenderer(((Font)font), _docRenderer).Render();
                }
            }
        }
Example #15
0
        /// <summary>
        /// Renders format and style. Always call EndFormatAndStyleAfterContent() after the content was written.
        /// </summary>
        protected void RenderStyleAndFormat()
        {
            object styleName    = GetValueAsIntended("Style");
            object parStyleName = styleName;
            Style  style        = this.docRenderer.Document.Styles[(string)styleName];

            this.hasCharacterStyle = false;
            if (style != null)
            {
                if (((Style)style).Type == StyleType.Character)
                {
                    this.hasCharacterStyle = true;
                    parStyleName           = "Normal";
                }
            }
            else
            {
                parStyleName = null;
            }

            if (parStyleName != null)
            {
                this.rtfWriter.WriteControl("s", this.docRenderer.GetStyleIndex((string)parStyleName));
            }

            ParagraphFormat frmt = GetValueAsIntended("Format") as ParagraphFormat;

            RendererFactory.CreateRenderer(frmt, this.docRenderer).Render();
            this.rtfWriter.WriteControl("brdrbtw");//Sollte Border trennen, funktioniert aber nicht.
            if (this.hasCharacterStyle)
            {
                this.rtfWriter.StartContent();
                this.rtfWriter.WriteControlWithStar("cs", this.docRenderer.GetStyleIndex((string)styleName));
                object font = GetValueAsIntended("Format.Font");
                if (font != null)
                {
                    new FontRenderer(((Font)font), this.docRenderer).Render();
                }
            }
        }
Example #16
0
        internal override void Render()
        {
            useEffectiveValue = true;
            Cell cvrgCell = this.cellList.GetCoveringCell(this.cell);

            if (this.cell.Column.Index != cvrgCell.Column.Index)
            {
                return;
            }

            bool writtenAnyContent = false;

            if (!this.cell.IsNull("Elements"))
            {
                if (this.cell == cvrgCell)
                {
                    foreach (DocumentObject docObj in this.cell.Elements)
                    {
                        RendererBase rndrr = RendererFactory.CreateRenderer(docObj, this.docRenderer);
                        if (rndrr != null)
                        {
                            rndrr.Render();
                            writtenAnyContent = true;
                        }
                    }
                }
            }
            if (!writtenAnyContent)
            {
                //Format attributes need to be set here to satisfy Word 2000.
                this.rtfWriter.WriteControl("pard");
                RenderStyleAndFormat();
                this.rtfWriter.WriteControl("intbl");
                EndStyleAndFormatAfterContent();
            }
            this.rtfWriter.WriteControl("cell");
        }
        /// <summary>
        /// Renders the style if it is a character style and the font of the formatted text.
        /// </summary>
        void RenderStyleAndFont()
        {
            bool hasCharacterStyle = false;

            if (!_formattedText.IsNull("Style"))
            {
                Style style = _formattedText.Document.Styles[_formattedText.Style];
                if (style != null && style.Type == StyleType.Character)
                {
                    hasCharacterStyle = true;
                }
            }
            object font = GetValueAsIntended("Font");

            if (font != null)
            {
                if (hasCharacterStyle)
                {
                    _rtfWriter.WriteControlWithStar("cs", _docRenderer.GetStyleIndex(_formattedText.Style));
                }

                RendererFactory.CreateRenderer(_formattedText.Font, _docRenderer).Render();
            }
        }
Example #18
0
        /// <summary>
        /// Renders a ParagraphFormat object.
        /// </summary>
        internal override void Render()
        {
            _useEffectiveValue = true; //unfortunately has to be true always.

            Translate("Alignment", "q");
            Translate("SpaceBefore", "sb");
            Translate("SpaceAfter", "sa");

            TranslateBool("WidowControl", "widctlpar", "nowidctlpar", false);
            Translate("PageBreakBefore", "pagebb");
            Translate("KeepTogether", "keep");
            Translate("KeepWithNext", "keepn");
            Translate("FirstLineIndent", "fi");

            Translate("LeftIndent", "li");
            Translate("LeftIndent", "lin");

            Translate("RightIndent", "ri");
            Translate("RightIndent", "rin");

            object ol = GetValueAsIntended("OutlineLevel");

            if (ol != null && ((OutlineLevel)ol) != OutlineLevel.BodyText)
            {
                Translate("OutlineLevel", "outlinelevel");
            }

            Unit            lineSpc     = (Unit)GetValueAsIntended("LineSpacing");
            LineSpacingRule lineSpcRule = (LineSpacingRule)GetValueAsIntended("LineSpacingRule");

            switch (lineSpcRule)
            {
            case LineSpacingRule.Exactly:     // A bit strange, but follows the RTF specification:
                _rtfWriter.WriteControl("sl", ToTwips(-lineSpc.Point));
                break;

            case LineSpacingRule.AtLeast:
                Translate("LineSpacing", "sl");
                break;

            case LineSpacingRule.Multiple:
                _rtfWriter.WriteControl("sl", ToRtfUnit(lineSpc, RtfUnit.Lines));
                break;

            case LineSpacingRule.Double:
                _rtfWriter.WriteControl("sl", 480);     // equals 12 * 2 * 20 (Standard line height * 2  in twips)
                break;

            case LineSpacingRule.OnePtFive:
                _rtfWriter.WriteControl("sl", 360);     // equals 12 * 1.5 * 20 (Standard lineheight * 1.5  in twips)
                break;
            }
            Translate("LineSpacingRule", "slmult");
            object shad = GetValueAsIntended("Shading");

            if (shad != null)
            {
                new ShadingRenderer((DocumentObject)shad, _docRenderer).Render();
            }

            object font = GetValueAsIntended("Font");

            if (font != null)
            {
                RendererFactory.CreateRenderer((Font)font, _docRenderer).Render();
            }

            object brdrs = GetValueAsIntended("Borders");

            if (brdrs != null)
            {
                BordersRenderer brdrsRndrr = new BordersRenderer((Borders)brdrs, _docRenderer);
                brdrsRndrr.ParentFormat = _format;
                brdrsRndrr.Render();
            }

            object tabStops = GetValueAsIntended("TabStops");

            if (tabStops != null)
            {
                RendererFactory.CreateRenderer((TabStops)tabStops, _docRenderer).Render();
            }

            // TODO: ListInfo is still under construction.
            object listInfo = GetValueAsIntended("ListInfo");

            if (listInfo != null)
            {
                int nr = ListInfoOverrideRenderer.GetListNumber((ListInfo)listInfo);
                if (nr > 0)
                {
                    _rtfWriter.WriteControl("ls", nr);
                }
            }
        }