Ejemplo n.º 1
0
        /// <summary>
        /// Creates a fitting renderer for the render info to render and layout with.
        /// </summary>
        /// <param name="gfx">The XGraphics object to render on.</param>
        /// <param name="documentRenderer">The document renderer.</param>
        /// <param name="renderInfo">The RenderInfo object stored after a previous call of Format().</param>
        /// <param name="fieldInfos">The field infos.</param>
        /// <returns>The fitting Renderer.</returns>
        internal static Renderer Create(XGraphics gfx, DocumentRenderer documentRenderer, RenderInfo renderInfo, FieldInfos fieldInfos)
        {
            Renderer renderer = null;

            if (renderInfo.DocumentObject is Paragraph)
            {
                renderer = new ParagraphRenderer(gfx, renderInfo, fieldInfos);
            }
            else if (renderInfo.DocumentObject is Table)
            {
                renderer = new TableRenderer(gfx, renderInfo, fieldInfos);
            }
            else if (renderInfo.DocumentObject is PageBreak)
            {
                renderer = new PageBreakRenderer(gfx, renderInfo, fieldInfos);
            }
            else if (renderInfo.DocumentObject is TextFrame)
            {
                renderer = new TextFrameRenderer(gfx, renderInfo, fieldInfos);
            }
            else if (renderInfo.DocumentObject is Chart)
            {
                renderer = new ChartRenderer(gfx, renderInfo, fieldInfos);
            }
            //else if (renderInfo.DocumentObject is Chart)
            //  renderer = new ChartRenderer(gfx, renderInfo, fieldInfos);
            else if (renderInfo.DocumentObject is Image image)
            {
                if (_xpsCheck.IsMatch(image.Name))
                {
                    renderer = new XpsRenderer(gfx, renderInfo, fieldInfos, documentRenderer.XpsCache);
                }
                else
                {
                    renderer = new ImageRenderer(gfx, renderInfo, fieldInfos);
                }
            }

            if (renderer != null)
            {
                renderer._documentRenderer = documentRenderer;
            }

            return(renderer);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a fitting renderer for the given document object for formatting.
        /// </summary>
        /// <param name="gfx">The XGraphics object to do measurements on.</param>
        /// <param name="documentRenderer">The document renderer.</param>
        /// <param name="documentObject">the document object to format.</param>
        /// <param name="fieldInfos">The field infos.</param>
        /// <returns>The fitting Renderer.</returns>
        internal static Renderer Create(XGraphics gfx, DocumentRenderer documentRenderer, DocumentObject documentObject, FieldInfos fieldInfos)
        {
            Renderer renderer = null;

            if (documentObject is Paragraph paragraph)
            {
                renderer = new ParagraphRenderer(gfx, paragraph, fieldInfos);
            }
            else if (documentObject is Table table)
            {
                renderer = new TableRenderer(gfx, table, fieldInfos);
            }
            else if (documentObject is PageBreak pageBreak)
            {
                renderer = new PageBreakRenderer(gfx, pageBreak, fieldInfos);
            }
            else if (documentObject is TextFrame textFrame)
            {
                renderer = new TextFrameRenderer(gfx, textFrame, fieldInfos);
            }
            else if (documentObject is Chart chart)
            {
                renderer = new ChartRenderer(gfx, chart, fieldInfos);
            }
            else if (documentObject is Image image)
            {
                if (_xpsCheck.IsMatch(image.Name))
                {
                    renderer = new XpsRenderer(gfx, image, fieldInfos, documentRenderer.XpsCache);
                }
                else
                {
                    renderer = new ImageRenderer(gfx, image, fieldInfos);
                }
            }

            if (renderer != null)
            {
                renderer._documentRenderer = documentRenderer;
            }

            return(renderer);
        }