예제 #1
0
        private void RenderFooter(XGraphics graphics, int page)
        {
            FormattedHeaderFooter formattedFooter = this.formattedDocument.GetFormattedFooter(page);

            if (formattedFooter == null)
            {
                return;
            }

            Rectangle footerArea = this.formattedDocument.GetFooterArea(page);

            RenderInfo[] renderInfos = formattedFooter.GetRenderInfos();
            XUnit        topY        = footerArea.Y + footerArea.Height - RenderInfo.GetTotalHeight(renderInfos);

            FieldInfos fieldInfos = this.formattedDocument.GetFieldInfos(page);

            foreach (RenderInfo renderInfo in renderInfos)
            {
                Renderer renderer = Renderer.Create(graphics, this, renderInfo, fieldInfos);
                XUnit    savedY   = renderer.RenderInfo.LayoutInfo.ContentArea.Y;
                renderer.RenderInfo.LayoutInfo.ContentArea.Y = topY;
                renderer.Render();
                renderer.RenderInfo.LayoutInfo.ContentArea.Y = savedY;
            }
        }
예제 #2
0
 internal void Format(XGraphics gfx)
 {
     this.gfx         = gfx;
     this.isFirstArea = true;
     this.formatter   = new TopDownFormatter(this, this.documentRenderer, this.headerFooter.Elements);
     this.formatter.FormatOnAreas(gfx, false);
     this.contentHeight = RenderInfo.GetTotalHeight(GetRenderInfos());
 }
예제 #3
0
 internal void Format(XGraphics gfx)
 {
     _gfx         = gfx;
     _isFirstArea = true;
     _formatter   = new TopDownFormatter(this, _documentRenderer, _headerFooter.Elements);
     _formatter.FormatOnAreas(gfx, false);
     _contentHeight = RenderInfo.GetTotalHeight(GetRenderInfos());
 }
예제 #4
0
        private XUnit CalcContentHeight(DocumentRenderer documentRenderer)
        {
            XUnit height = RenderInfo.GetTotalHeight(GetRenderInfos());

            if (height == 0)
            {
                height  = ParagraphRenderer.GetLineHeight(_cell.Format, _gfx, documentRenderer);
                height += _cell.Format.SpaceBefore;
                height += _cell.Format.SpaceAfter;
            }
            return(height);
        }
        private void RenderFooter(XGraphics graphics, int page)
        {
            FormattedHeaderFooter formattedFooter = _formattedDocument.GetFormattedFooter(page);

            if (formattedFooter == null)
            {
                return;
            }

            Rectangle footerArea = _formattedDocument.GetFooterArea(page);

            RenderInfo[] renderInfos = formattedFooter.GetRenderInfos();
#if true
#if true
            // The footer is bottom-aligned and grows with its contents. topY specifies the Y position where the footer begins.
            XUnit topY = footerArea.Y + footerArea.Height - RenderInfo.GetTotalHeight(renderInfos);
            // Hack: The purpose of "topY" is unclear, but two paragraphs in the footer will use the same topY and will be rendered at the same position.
            // offsetY specifies the offset (amount of movement) for all footer items. It's the difference between topY and the position calculated for the first item.
            XUnit offsetY  = 0;
            bool  notFirst = false;

            FieldInfos fieldInfos = _formattedDocument.GetFieldInfos(page);
            foreach (RenderInfo renderInfo in renderInfos)
            {
                Renderer renderer = Renderer.Create(graphics, this, renderInfo, fieldInfos);
                if (!notFirst)
                {
                    offsetY  = renderer.RenderInfo.LayoutInfo.ContentArea.Y - topY;
                    notFirst = true;
                }
                XUnit savedY = renderer.RenderInfo.LayoutInfo.ContentArea.Y;
                // Apply offsetY only to items that do not have an absolute position.
                if (renderer.RenderInfo.LayoutInfo.Floating != Floating.None)
                {
                    renderer.RenderInfo.LayoutInfo.ContentArea.Y -= offsetY;
                }
                renderer.Render();
                renderer.RenderInfo.LayoutInfo.ContentArea.Y = savedY;
            }
#else
            // TODO Document the purpose of "topY".
            XUnit topY = footerArea.Y + footerArea.Height - RenderInfo.GetTotalHeight(renderInfos);
            // Hack: The purpose of "topY" is unclear, but two paragraphs in the footer will use the same topY and will be rendered at the same position.
            XUnit offsetY = 0;

            FieldInfos fieldInfos = _formattedDocument.GetFieldInfos(page);
            foreach (RenderInfo renderInfo in renderInfos)
            {
                Renderer renderer = Renderer.Create(graphics, this, renderInfo, fieldInfos);
                XUnit    savedY   = renderer.RenderInfo.LayoutInfo.ContentArea.Y;
                renderer.RenderInfo.LayoutInfo.ContentArea.Y = topY + offsetY;
                renderer.Render();
                renderer.RenderInfo.LayoutInfo.ContentArea.Y = savedY;
                offsetY += renderer.RenderInfo.LayoutInfo.ContentArea.Height;
            }
#endif
#else
            XUnit topY = footerArea.Y + footerArea.Height - RenderInfo.GetTotalHeight(renderInfos);

            FieldInfos fieldInfos = _formattedDocument.GetFieldInfos(page);
            foreach (RenderInfo renderInfo in renderInfos)
            {
                Renderer renderer = Renderer.Create(graphics, this, renderInfo, fieldInfos);
                XUnit    savedY   = renderer.RenderInfo.LayoutInfo.ContentArea.Y;
                renderer.RenderInfo.LayoutInfo.ContentArea.Y = topY;
                renderer.Render();
                renderer.RenderInfo.LayoutInfo.ContentArea.Y = savedY;
            }
#endif
        }