Beispiel #1
0
        public Page GetPage(PageNumberInfo number)
        {
            if (ModifiedPages.TryGetValue(number, out var dirtyPage))
            {
                return(dirtyPage);
            }

            if (AllocatedPages.Contains(number))
            {
                return(CreatePage(number));
            }

            var poolPage = Pool.GetEntry(number);

            if (poolPage != null)
            {
                return(poolPage);
            }

            var page = PageManager.GetPage(number);

            if (page == null)
            {
                throw null;
            }

            Pool.AddEntry(page, PageEntryState.None);

            return(page);
        }
Beispiel #2
0
        public void Free(PageNumberInfo page)
        {
            var pager = Provider.GetPager(page.StoreId);

            if (pager == null)
            {
                throw new NullReferenceException(nameof(pager));
            }
        }
Beispiel #3
0
        public virtual Page GetEntry(PageNumberInfo number)
        {
            if (_buffers.TryGetValue(number, out var bufferEntry))
            {
                Interlocked.Add(ref bufferEntry.Version, 1);
                return(bufferEntry.Page);
            }

            return(null);
        }
        internal void IncLogicalPageNumber()
        {
            logicalPageNo++;
            int index = CurPage - firstReportPage;

            if (FirstPass || index >= pageNumbers.Count)
            {
                PageNumberInfo info = new PageNumberInfo(logicalPageNo);
                pageNumbers.Add(info);
            }
        }
Beispiel #5
0
        public void SetPage(PageNumberInfo number, Page page)
        {
            var pager = Provider.GetPager(number.StoreId);

            if (pager == null)
            {
                throw new NullReferenceException(nameof(pager));
            }

            pager.SetPage(number.PageNumber, page.Data);
        }
Beispiel #6
0
        public Page GetPage(PageNumberInfo number)
        {
            var pager = Provider.GetPager(number.StoreId);

            if (pager == null)
            {
                throw new NullReferenceException(nameof(pager));
            }

            return(new Page(pager.GetPage(number.PageNumber)));
        }
        internal void IncLogicalPageNumber()
        {
            FLogicalPageNo++;
            int index = CurPage - FFirstReportPage;

            if (FirstPass || index >= FPageNumbers.Count)
            {
                PageNumberInfo info = new PageNumberInfo();
                FPageNumbers.Add(info);
                info.PageNo = FLogicalPageNo;
            }
        }
Beispiel #8
0
        public virtual PageNumberInfo[] Allocate(uint count)
        {
            var start = AddPage(count);
            var pages = new PageNumberInfo[count];

            for (var i = 0; i < count; i++)
            {
                pages[i] = new PageNumberInfo(Store.Id, start + i);
            }

            return(pages);
        }
        /// <summary>
        /// Called when the number of pages increased during DoublePass
        /// </summary>
        internal void ShiftLastPage()
        {
            PageNumberInfo info = new PageNumberInfo(pageNumbers.Count + 1);

            pageNumbers.Add(info);


            for (int i = pageNumbers.Count - 1; i >= 0; i--)
            {
                info            = pageNumbers[i];
                info.totalPages = pageNumbers.Count;
            }
        }
Beispiel #10
0
        protected override string GetValue(IDocumentData documentData, PageNumberInfo pageNumberInfo, DocumentProperties documentProperties)
        {
            if (!string.IsNullOrEmpty(HideValue))
            {
                var result = documentData.Get(HideValue);
                if (string.IsNullOrEmpty(result))
                {
                    return(string.Empty);
                }
            }

            return(Value.ParseValue(documentData, pageNumberInfo, documentProperties));
        }
Beispiel #11
0
        public Page ModifyPage(PageNumberInfo number)
        {
            if (ModifiedPages.TryGetValue(number, out var page))
            {
                return(page);
            }

            var oldPage = GetPage(number);
            var newPage = ModifyPage(oldPage);

            if (!ModifiedPages.TryAdd(number, newPage))
            {
                throw new InvalidOperationException($"modify page {number.PageNumber} failed!");
            }

            return(newPage);
        }
        /// <summary>
        /// Resets the logical page numbers.
        /// </summary>
        public void ResetLogicalPageNumber()
        {
            if (!FirstPass)
            {
                return;
            }

            for (int i = pageNumbers.Count - 1; i >= 0; i--)
            {
                PageNumberInfo info = pageNumbers[i];
                info.totalPages = logicalPageNo;
                if (info.pageNo == 1)
                {
                    break;
                }
            }

            logicalPageNo = 0;
        }
Beispiel #13
0
 protected abstract string GetValue(IDocumentData documentData, PageNumberInfo pageNumberInfo, DocumentProperties documentProperties);
Beispiel #14
0
 protected internal Page CreatePage(PageNumberInfo number)
 {
     var     page   = new Page();
     ref var header = ref page.PageHeader;
        public static string ParseValue(this string value, IDocumentData documentData, PageNumberInfo pageNumberInfo, DocumentProperties documentProperties, bool returnErrorMessage = true)
        {
            if (string.IsNullOrEmpty(value))
            {
                return(value);
            }

            //Pick data fields and replace them with correct data
            var parsedValue = value;

            var startIndex = 0;
            var pos        = parsedValue.IndexOf("{", startIndex, StringComparison.Ordinal);

            while (pos != -1)
            {
                var posE     = parsedValue.IndexOf("}", pos, StringComparison.Ordinal);
                var dataName = parsedValue.Substring(pos + 1, posE - pos - 1);

                string dataValue = null;
                if (pageNumberInfo != null)
                {
                    dataValue = pageNumberInfo.GetPageNumberInfo(dataName);
                }

                switch (dataName)
                {
                case "Author":
                    dataValue = documentProperties.Author;
                    break;

                case "Subject":
                    dataValue = documentProperties.Subject;
                    break;

                case "Title":
                    dataValue = documentProperties.Title;
                    break;

                case "Creator":
                    dataValue = documentProperties.Creator;
                    break;
                }

                if (dataValue == null)
                {
                    dataValue = (documentData != null && documentData.Get(dataName) != null) ? documentData.Get(dataName) : (returnErrorMessage ? string.Format("[Data '{0}' is missing]", dataName) : string.Empty);
                }

                startIndex  = pos + dataValue.Length;
                parsedValue = string.Format("{0}{1}{2}", parsedValue.Substring(0, pos), dataValue, parsedValue.Substring(posE + 1));

                pos = parsedValue.IndexOf("{", startIndex, StringComparison.Ordinal);
            }

            return(parsedValue.TrimEnd(' '));
        }
Beispiel #16
0
 private string GetCode(IDocumentData documentData, PageNumberInfo pageNumberInfo)
 {
     return(Code.ParseValue(documentData, pageNumberInfo, null));
 }
Beispiel #17
0
        private void DoRenderStuff(IGraphics gfx, XRect size, bool preRender, int page, int?totalPages, bool includeBackgroundObjects, XRect actualPaperMargin)
        {
            var postRendering = new List <Action>();

            var pageNumberInfo = new PageNumberInfo(page + 1, totalPages);

            var section = GetSection(preRender, page);

            var sectionBounds = new XRect(section.Margin.GetLeft(size.Width) - actualPaperMargin.Left, section.Margin.GetTop(size.Height) - actualPaperMargin.Top, section.Margin.GetWidht(size.Width), section.Margin.GetHeight(size.Height));

            if (_debugData != null)
            {
                var sectionName = string.IsNullOrEmpty(section.Name) ? "Unnamed section" : section.Name;
                var textSize    = gfx.MeasureString(sectionName, _debugData.Font);
                gfx.DrawString(sectionName, _debugData.Font, _debugData.Brush, new XPoint(0, textSize.Height));

                //Left margin
                gfx.DrawLine(_debugData.Pen, sectionBounds.Left, 0, sectionBounds.Left, size.Height);

                //Right margin
                gfx.DrawLine(_debugData.Pen, sectionBounds.Right, 0, sectionBounds.Right, size.Height);

                //Top margin
                gfx.DrawLine(_debugData.Pen, 0, sectionBounds.Top, size.Width, sectionBounds.Top);

                //Bottom margin
                gfx.DrawLine(_debugData.Pen, 0, sectionBounds.Bottom, size.Width, sectionBounds.Bottom);
            }

            var headerHeight = section.Header.Height.ToXUnit(sectionBounds.Height);
            var footerHeight = section.Footer.Height.ToXUnit(sectionBounds.Height);
            var paneBounds   = new XRect(sectionBounds.Left, sectionBounds.Top + headerHeight, sectionBounds.Width, sectionBounds.Height - headerHeight - footerHeight);

            var renderData = new RenderData(gfx, paneBounds, section, _documentData, pageNumberInfo, _debugData, includeBackgroundObjects, _documentProperties);

            if (preRender)
            {
                var pageCountPane   = section.Pane.PreRender(renderData);
                var pageCountFooter = section.Footer.PreRender(renderData);
                var pageCountHeader = section.Header.PreRender(renderData);
                var pageCount       = Max(pageCountPane, pageCountFooter, pageCountHeader);
                section.SetRenderPageCount(pageCount);
            }
            else
            {
                section.Pane.Render(renderData, page);

                //Header
                if (section.Header != null)
                {
                    if (Math.Abs(headerHeight) < 0.0001 && section.Header.ElementList.Any())
                    {
                        throw new InvalidOperationException("No height for the header has been set, but there are elements there.").AddData("ElementCount", section.Header.ElementList.Count);
                    }

                    var bounds           = new XRect(sectionBounds.Left, sectionBounds.Top, sectionBounds.Width, headerHeight);
                    var renderDataHeader = new RenderData(gfx, bounds, section, _documentData, pageNumberInfo, _debugData, includeBackgroundObjects, _documentProperties);
                    postRendering.Add(() => section.Header.Render(renderDataHeader, page));

                    if (_debugData != null)
                    {
                        gfx.DrawLine(_debugData.Pen, bounds.Left, bounds.Bottom, bounds.Right, bounds.Bottom);
                    }
                }

                //Footer
                if (section.Footer != null)
                {
                    if (Math.Abs(footerHeight) < 0.0001 && section.Footer.ElementList.Any())
                    {
                        throw new InvalidOperationException("No height for the footer has been set, but there are elements there.").AddData("ElementCount", section.Footer.ElementList.Count);
                    }

                    var bounds           = new XRect(sectionBounds.Left, sectionBounds.Bottom - footerHeight, sectionBounds.Width, footerHeight);
                    var renderDataFooter = new RenderData(gfx, bounds, section, _documentData, pageNumberInfo, _debugData, includeBackgroundObjects, _documentProperties);
                    postRendering.Add(() => section.Footer.Render(renderDataFooter, page));

                    if (_debugData != null)
                    {
                        gfx.DrawLine(_debugData.Pen, bounds.Left, bounds.Top, bounds.Right, bounds.Top);
                    }
                }
            }

            foreach (var action in postRendering)
            {
                action();
            }
        }