Пример #1
0
 private void CreateFirstSectionBodyFromPaginationState(int page, ReportSectionHelper lastPageInfo, ref PageItemHelper lastBodyInfo, ref int sectionStartIndex)
 {
     if (lastPageInfo != null)
     {
         sectionStartIndex = lastPageInfo.SectionIndex;
         m_sections[sectionStartIndex].UpdateItem(lastPageInfo);
         if (lastPageInfo.BodyHelper != null)
         {
             lastBodyInfo = lastPageInfo.BodyHelper;
         }
         else
         {
             sectionStartIndex++;
         }
         return;
     }
     if (page == 1)
     {
         sectionStartIndex = 0;
         m_sections[sectionStartIndex].Reset();
         return;
     }
     RSTrace.RenderingTracer.Assert(m_lastSectionIndex >= 0 && m_lastSectionIndex < m_sections.Count, "The index of the last section on the previous paginated page should be a valid index");
     if (m_sections[m_lastSectionIndex].Done && m_lastSectionIndex < m_sections.Count - 1)
     {
         m_sections[m_lastSectionIndex].Reset();
         sectionStartIndex = m_lastSectionIndex + 1;
     }
     else
     {
         sectionStartIndex = m_lastSectionIndex;
         m_sections[sectionStartIndex].Reset();
     }
 }
Пример #2
0
        internal ReportSectionHelper WritePaginationInfo()
        {
            ReportSectionHelper reportSectionHelper = new ReportSectionHelper();

            WritePaginationInfoProperties(reportSectionHelper);
            return(reportSectionHelper);
        }
Пример #3
0
        internal void ReadPageInfo(int page, out ReportSectionHelper pageInfo)
        {
            RSTrace.RenderingTracer.Assert(m_stream != null, "The pagination stream is null.");
            RSTrace.RenderingTracer.Assert(m_paginatedPages >= 0, "The number of paginated pages is negative.");
            RSTrace.RenderingTracer.Assert(page >= 0 && page <= m_paginatedPages, "The number of the solicited page is outside of the interval: 0 - " + m_paginatedPages.ToString(CultureInfo.InvariantCulture) + ".");
            pageInfo = null;
            switch (page)
            {
            case 0:
                return;

            case 1:
            {
                BinaryReader.BaseStream.Seek(m_offsetHeader, SeekOrigin.Begin);
                long offsetEndPage = m_metadataPages[0];
                if (RSTrace.RenderingTracer.TraceVerbose)
                {
                    RSTrace.RenderingTracer.Trace(TraceLevel.Verbose, "We extract from stream the page: " + page.ToString(CultureInfo.InvariantCulture));
                }
                pageInfo = ReportSectionHelper.ReadReportSection(BinaryReader, offsetEndPage);
                return;
            }
            }
            long offset         = m_metadataPages[page - 2];
            long offsetEndPage2 = m_metadataPages[page - 1];

            BinaryReader.BaseStream.Seek(offset, SeekOrigin.Begin);
            if (RSTrace.RenderingTracer.TraceVerbose)
            {
                RSTrace.RenderingTracer.Trace(TraceLevel.Verbose, "We extract from stream the page: " + page.ToString(CultureInfo.InvariantCulture));
            }
            pageInfo = ReportSectionHelper.ReadReportSection(BinaryReader, offsetEndPage2);
        }
Пример #4
0
 internal void UpdateItem(ReportSectionHelper sectionHelper)
 {
     if (sectionHelper != null)
     {
         m_sectionIndex = sectionHelper.SectionIndex;
         m_bodyHelper   = sectionHelper.BodyHelper;
     }
 }
Пример #5
0
 internal void WritePaginationInfoProperties(ReportSectionHelper sectionHelper)
 {
     if (sectionHelper != null)
     {
         sectionHelper.SectionIndex = m_sectionIndex;
         if (m_body != null && !Done)
         {
             sectionHelper.BodyHelper = m_body.WritePaginationInfo();
         }
     }
 }
Пример #6
0
 private static void ReadReportSectionProperties(ReportSectionHelper section, BinaryReader reader, long offsetEndPage)
 {
     RSTrace.RenderingTracer.Assert(section != null, "The section helper is null.");
     RSTrace.RenderingTracer.Assert(reader != null, "The pagination stream is null.");
     RSTrace.RenderingTracer.Assert(offsetEndPage > 0, "The pagination stream is corrupt.");
     if (reader.ReadByte() == 23)
     {
         section.SectionIndex = reader.ReadInt32();
         section.BodyHelper   = PageItemHelper.ReadItems(reader, offsetEndPage);
         reader.ReadByte();
         if (reader.BaseStream.Position > offsetEndPage)
         {
             throw new InvalidDataException(SPBRes.InvalidPaginationStream);
         }
         return;
     }
     throw new InvalidDataException(SPBRes.InvalidPaginationStream);
 }
Пример #7
0
        internal static ReportSectionHelper ReadReportSection(BinaryReader reader, long offsetEndPage)
        {
            if (reader == null || offsetEndPage <= 0)
            {
                return(null);
            }
            _ = reader.BaseStream.Position;
            ReportSectionHelper reportSectionHelper = null;
            byte b = reader.ReadByte();

            if (b == 16)
            {
                reportSectionHelper = new ReportSectionHelper();
                ReadReportSectionProperties(reportSectionHelper, reader, offsetEndPage);
                if (reader.BaseStream.Position > offsetEndPage)
                {
                    throw new InvalidDataException(SPBRes.InvalidPaginationStream);
                }
                return(reportSectionHelper);
            }
            throw new InvalidDataException(SPBRes.InvalidTokenPaginationItems(b.ToString("x", CultureInfo.InvariantCulture)));
        }
Пример #8
0
        internal void NextPage(RPLWriter rplWriter, ref ReportSectionHelper lastPageInfo, int page, int totalPages, Interactivity interactivity, bool hasPaginationChunk)
        {
            ReportSection  reportSection     = null;
            bool           flag              = true;
            bool           flag2             = false;
            bool           flag3             = false;
            bool           flag4             = (m_sections.Count <= 1) ? true : false;
            PageItemHelper lastBodyInfo      = null;
            int            pageNumber        = page;
            int            totalPages2       = totalPages;
            int            sectionStartIndex = -1;

            CreateFirstSectionBodyFromPaginationState(page, lastPageInfo, ref lastBodyInfo, ref sectionStartIndex);
            if (m_pageContext.ImageConsolidation != null)
            {
                m_pageContext.ImageConsolidation.Reset();
                m_pageContext.ImageConsolidation.SetName(m_report.Name, page);
            }
            m_pageContext.PageNumber = page;
            m_pageContext.PageTotalInfo.RegisterPageNumberForStart(page);
            m_pageContext.PageTotalInfo.RetrievePageBreakData(page, out pageNumber, out totalPages2);
            WriteStartItemToStream(rplWriter);
            WriteReportPageLayoutAtStart(rplWriter);
            for (int i = sectionStartIndex; i < m_sections.Count; i++)
            {
                ReportSection reportSection2    = m_sections[i];
                bool          delayedHeader     = false;
                bool          delayedFooter     = false;
                bool          lastSectionOnPage = false;
                if (flag)
                {
                    reportSection = reportSection2;
                }
                if (i == m_sections.Count - 1)
                {
                    flag4 = true;
                }
                if (reportSection2.Body == null)
                {
                    reportSection2.SetContext();
                }
                reportSection2.CalculatePage(rplWriter, page, totalPages, pageNumber, totalPages2, flag, flag4, interactivity, m_pageContext.PageHeight, ref lastBodyInfo, ref delayedHeader, ref delayedFooter, ref lastSectionOnPage);
                if (m_pageContext.CancelPage)
                {
                    ResetSectionsOnPage(sectionStartIndex, i);
                    return;
                }
                if (flag)
                {
                    flag         = false;
                    flag2        = delayedHeader;
                    lastPageInfo = null;
                }
                if (delayedFooter)
                {
                    flag3 = delayedFooter;
                }
                m_sectionSizes.Add(reportSection2.ItemRenderSizes);
                m_sectionOffsets.Add(reportSection2.Offset);
                if (m_pageContext.PageHeight != double.MaxValue)
                {
                    m_pageContext.PageHeight -= reportSection2.Body.ItemPageSizes.Height;
                }
                if (lastSectionOnPage)
                {
                    if (i > m_lastSectionIndex)
                    {
                        m_lastSectionIndex = i;
                    }
                    reportSection2.SectionIndex = i;
                    break;
                }
            }
            if (m_pageContext.TracingEnabled)
            {
                if (Done)
                {
                    TracePageBreakIgnoredAtBottom(page, m_pageContext.Common.PageBreakInfo);
                }
                else if (m_pageContext.Common.PageBreakInfo != null)
                {
                    TraceLogicalPageBreak(page + 1, m_pageContext.Common.PageBreakInfo);
                }
                else
                {
                    TraceVerticalPageBreak(page + 1);
                }
            }
            m_pageContext.ApplyPageBreak(page);
            int    num        = 1;
            double bodyWidth  = 0.0;
            double bodyHeight = 0.0;
            bool   flag5      = flag4 && m_sections[m_lastSectionIndex].Done;

            if (m_pageContext.VersionPicker == RPLVersionEnum.RPL2008 || m_pageContext.VersionPicker == RPLVersionEnum.RPL2008WithImageConsolidation)
            {
                WriteEndReportBodyToRPLStream2008(rplWriter, sectionStartIndex, ref bodyWidth, ref bodyHeight);
                if (rplWriter != null || (interactivity != null && !interactivity.Done && interactivity.NeedPageHeaderFooter))
                {
                    WriteReportPageLayout2008(rplWriter, bodyWidth, bodyHeight);
                    if (flag3)
                    {
                        m_sections[m_lastSectionIndex].CalculateDelayedFooter(rplWriter, interactivity);
                        num++;
                    }
                    if (flag2 && (page == 1 || !flag5 || reportSection.IsHeaderPrintOnLastPage()))
                    {
                        reportSection.CalculateDelayedHeader(rplWriter, interactivity);
                        num++;
                    }
                    if (rplWriter != null && rplWriter.BinaryWriter != null)
                    {
                        rplWriter.BinaryWriter.Write(byte.MaxValue);
                    }
                }
            }
            else if (flag2)
            {
                if (!flag5)
                {
                    CalculateDelayedHeader(rplWriter, reportSection, interactivity);
                }
                else
                {
                    reportSection.WriteEndItemToStream(rplWriter);
                    if (rplWriter != null)
                    {
                        m_sectionSizes[0].Height = reportSection.ItemRenderSizes.Height;
                        m_sectionSizes[0].Width  = reportSection.ItemRenderSizes.Width;
                        m_sectionOffsets[0]      = reportSection.Offset;
                    }
                }
            }
            interactivity?.RegisterDocMapRootLabel(m_report.Instance.UniqueName, m_pageContext);
            if (m_pageContext.ImageConsolidation != null)
            {
                m_pageContext.ImageConsolidation.RenderToStream();
            }
            string pageName = m_pageContext.PageTotalInfo.GetPageName(page);

            WriteEndItemToStream(rplWriter, sectionStartIndex, num, reportSection.Header, m_sections[m_lastSectionIndex].Footer, bodyWidth, bodyHeight, pageName);
            m_pageContext.PageHeight = m_pageContext.OriginalPageHeight;
            if (hasPaginationChunk)
            {
                ReleaseResourcesOnPage(rplWriter, sectionStartIndex, includeLastSection: false);
            }
            else
            {
                ReleaseResourcesOnPage(rplWriter, sectionStartIndex, includeLastSection: true);
            }
        }