private void CutObjects() { keepCurX = CurX; keepDeltaY = CurY - keepCurY; PreparedPages.CutObjects(keepPosition); CurY = keepCurY; }
private void StartPage() { // apply Right to Left layout if needed if (Config.RightToLeft) { CurX = page.Columns.Positions[page.Columns.Positions.Count - 1] * Units.Millimeters; } else { CurX = 0; } CurY = 0; curColumn = 0; PreparedPages.AddPage(page); AddPageOutline(); if (page.Overlay != null) { ShowBand(page.Overlay); } ShowPageHeader(); OnStateChanged(page, EngineState.PageStarted); columnStartY = CurY; StartColumn(); ShowProgress(); }
internal void RunPhase2() { try { Config.ReportSettings.OnStartProgress(Report); PrepareToFirstPass(false); RunReportPages(); ResetLogicalPageNumber(); if (Report.DoublePass && !Report.Aborted) { finalPass = true; PrepareToSecondPass(); RunReportPages(); } } finally { Report.OnFinishReport(EventArgs.Empty); Config.ReportSettings.OnFinishProgress(Report); Report.SetOperation(ReportOperation.None); // limit the prepared pages if (Report.MaxPages > 0) { while (PreparedPages.Count > Report.MaxPages) { PreparedPages.RemovePage(PreparedPages.Count - 1); } } } }
private void PrepareToSecondPass() { Report.Dictionary.Totals.ClearValues(); objectsToProcess.Clear(); PreparedPages.ClearFirstPass(); InitializeSecondPassData(); }
private void GeneratePagesWrapped() { ReportEngine engine = Report.Engine; PreparedPages preparedPages = Report.PreparedPages; preparedPages.CanUploadToCache = false; List <Rectangle> spans = GetSpanList(); int startColumn = 0; Top = 0; while (startColumn < Columns.Count) { int startRow = 0; int columnsFit = GetColumnsFit(startColumn, engine.PageWidth - Left); // avoid the infinite loop if there is not enough space for one column if (startColumn > 0 && columnsFit == 0) { columnsFit = 1; } while (startRow < Rows.Count) { int rowsFit = GetRowsFit(startRow, engine.FreeSpace); if (startRow == 0 && engine.IsKeeping && rowsFit < RowCount && isFirstRow && engine.KeepCurY > 0) { engine.EndColumn(); rowsFit = GetRowsFit(startRow, engine.FreeSpace); } if (rowsFit == 0) { engine.StartNewPage(); rowsFit = GetRowsFit(startRow, engine.FreeSpace); } engine.CurY += GeneratePage(startColumn, startRow, columnsFit, rowsFit, new RectangleF(0, 0, engine.PageWidth, engine.FreeSpace), spans); startRow += rowsFit; if (Report.Aborted) { break; } } startColumn += columnsFit; if (startColumn < Columns.Count) { engine.CurY += WrappedGap; } if (Report.Aborted) { break; } } }
internal bool Run(bool runDialogs, bool append, bool resetDataState, ReportPage page) { date = SystemFake.DateTime.Now; Report.SetOperation(ReportOperation.Running); ResetDesigningFlag(); // don't reset the data state if we run the hyperlink's detail page or refresh a report. // This is necessary to keep data filtering settings alive if (resetDataState) { InitializeData(); } Report.OnStartReport(EventArgs.Empty); try { if (runDialogs && !RunDialogs()) { return(false); } Config.ReportSettings.OnStartProgress(Report); PrepareToFirstPass(append); RunReportPages(page); ResetLogicalPageNumber(); if (Report.DoublePass && !Report.Aborted) { finalPass = true; PrepareToSecondPass(); RunReportPages(page); } } finally { Report.OnFinishReport(EventArgs.Empty); Config.ReportSettings.OnFinishProgress(Report); Report.SetOperation(ReportOperation.None); // limit the prepared pages if (Report.MaxPages > 0) { while (PreparedPages.Count > Report.MaxPages) { PreparedPages.RemovePage(PreparedPages.Count - 1); } } // Limit the prepared pages again because pagesLimit has better priority than Report.MaxPages. if (pagesLimit > 0) { while (PreparedPages.Count > pagesLimit) { PreparedPages.RemovePage(PreparedPages.Count - 1); } } } return(true); }
private void PasteObjects() { PreparedPages.PasteObjects(CurX - keepCurX, CurY - keepCurY); PreparedPages.Outline.Shift(keepOutline, CurY); PreparedPages.Bookmarks.Shift(keepBookmarks, CurY); EndKeep(); CurY += keepDeltaY; }
private void PasteObjects() { PreparedPages.PasteObjects(FOriginX + CurX, CurY); PreparedPages.Outline.Shift(FKeepOutline, CurY); PreparedPages.Bookmarks.Shift(FKeepBookmarks, CurY); EndKeep(); CurY += FKeepDeltaY; }
private void DoDetailedPage(string objectName, string paramName, string paramValue) { if (!String.IsNullOrEmpty(objectName)) { Report currentReport = CurrentTab.NeedParent ? Tabs[0].Report : Report; ReportComponentBase obj = currentReport.FindObject(objectName) as ReportComponentBase; if (obj != null && obj.Hyperlink.Kind == HyperlinkKind.DetailPage) { ReportPage reportPage = currentReport.FindObject(obj.Hyperlink.DetailPageName) as ReportPage; if (reportPage != null) { Data.Parameter param = currentReport.Parameters.FindByName(paramName); if (param != null && param.ChildObjects.Count > 0) { string[] paramValues = paramValue.Split(obj.Hyperlink.ValuesSeparator[0]); if (paramValues.Length > 0) { int i = 0; foreach (Data.Parameter childParam in param.ChildObjects) { childParam.Value = paramValues[i++]; if (i >= paramValues.Length) { break; } } } } else { currentReport.SetParameterValue(paramName, paramValue); } PreparedPages oldPreparedPages = currentReport.PreparedPages; PreparedPages pages = new PreparedPages(currentReport); currentReport.SetPreparedPages(pages); currentReport.PreparePage(reportPage); Report tabReport = new Report(); tabReport.SetPreparedPages(currentReport.PreparedPages); Tabs.Add(new ReportTab() { Name = paramValue, Report = tabReport, ReportPrepared = true, Closeable = true, NeedParent = true }); int prevTab = CurrentTabIndex; currentReport.SetPreparedPages(oldPreparedPages); CurrentTabIndex = Tabs.Count - 1; //Prop.PreviousTab = prevTab; } } } }
private void InitializePages() { for (int i = 0; i < Report.Pages.Count; i++) { ReportPage page = Report.Pages[i] as ReportPage; if (page != null) { PreparedPages.AddSourcePage(page); } } }
internal bool Run(bool runDialogs, bool append, bool resetDataState, ReportPage page) { RunPhase1(resetDataState); try { if (runDialogs && !RunDialogs()) { return(false); } Config.ReportSettings.OnStartProgress(Report); PrepareToFirstPass(append); RunReportPages(page); ResetLogicalPageNumber(); if (Report.DoublePass && !Report.Aborted) { finalPass = true; PrepareToSecondPass(); RunReportPages(page); } } finally { RestoreTemplate(); Report.OnFinishReport(EventArgs.Empty); Config.ReportSettings.OnFinishProgress(Report); Report.SetOperation(ReportOperation.None); // limit the prepared pages if (Report.MaxPages > 0) { while (PreparedPages.Count > Report.MaxPages) { PreparedPages.RemovePage(PreparedPages.Count - 1); } } // Limit the prepared pages again because pagesLimit has better priority than Report.MaxPages. if (pagesLimit > 0) { while (PreparedPages.Count > pagesLimit) { PreparedPages.RemovePage(PreparedPages.Count - 1); } } } return(true); }
private void RunReportPage(ReportPage page) { this.page = page; InitReprint(); pageNameForRecalc = null; this.page.OnStartPage(EventArgs.Empty); bool previousPage = StartFirstPage(); OnStateChanged(this.page, EngineState.ReportPageStarted); OnStateChanged(this.page, EngineState.PageStarted); DataBand keepSummaryBand = FindDeepmostDataBand(page); if (keepSummaryBand != null) { keepSummaryBand.KeepSummary = true; } if (this.page.IsManualBuild) { this.page.OnManualBuild(EventArgs.Empty); } else { RunBands(page.Bands); } OnStateChanged(this.page, EngineState.PageFinished); OnStateChanged(this.page, EngineState.ReportPageFinished); EndLastPage(); //recalculate unlimited if (page.UnlimitedHeight || page.UnlimitedWidth) { PreparedPages.ModifyPageSize(page.Name); if (previousPage && pageNameForRecalc != null) { PreparedPages.ModifyPageSize(pageNameForRecalc); } } //recalculate unlimited this.page.OnFinishPage(EventArgs.Empty); if (this.page.BackPage) { PreparedPages.InterleaveWithBackPage(PreparedPages.CurPage); } }
internal void RunPhase2(int?pagesLimit = null) { if (pagesLimit != null) { this.pagesLimit = pagesLimit.Value; } try { Config.ReportSettings.OnStartProgress(Report); PrepareToFirstPass(false); RunReportPages(); ResetLogicalPageNumber(); if (Report.DoublePass && !Report.Aborted) { finalPass = true; PrepareToSecondPass(); RunReportPages(); } } finally { Report.OnFinishReport(EventArgs.Empty); Config.ReportSettings.OnFinishProgress(Report); Report.SetOperation(ReportOperation.None); // limit the prepared pages if (Report.MaxPages > 0) { while (PreparedPages.Count > Report.MaxPages) { PreparedPages.RemovePage(PreparedPages.Count - 1); } } // Limit the prepared pages again because pagesLimit has better priority than Report.MaxPages. if (pagesLimit > 0) { while (PreparedPages.Count > pagesLimit) { PreparedPages.RemovePage(PreparedPages.Count - 1); } } } }
private void PrepareToFirstPass(bool append) { finalPass = !Report.DoublePass; if (!append) { PreparedPages.Clear(); } else { PreparedPages.CurPage = PreparedPages.Count > 0 ? PreparedPages.Count - 1 : 0; } isFirstReportPage = true; hierarchyLevel = 1; PreparedPages.PrepareToFirstPass(); Report.Dictionary.Totals.ClearValues(); objectsToProcess.Clear(); InitializePages(); InitPageNumbers(); }
private void StartPage() { CurX = 0; CurY = 0; FCurColumn = 0; PreparedPages.AddPage(FPage); AddPageOutline(); if (FPage.Overlay != null) { ShowBand(FPage.Overlay); } ShowPageHeader(); OnStateChanged(FPage, EngineState.PageStarted); FColumnStartY = CurY; StartColumn(); ShowProgress(); }
private void ClearFirstPass() { Report.Dictionary.Totals.ClearValues(); FObjectsToProcess.Clear(); PreparedPages.ClearFirstPass(); }
private bool StartFirstPage() { page.InitializeComponents(); CurX = 0; CurY = 0; curColumn = 0; if (page.ResetPageNumber) { ResetLogicalPageNumber(); } bool previousPage = page.PrintOnPreviousPage && PreparedPages.Count > 0; // check that previous page has the same size if (previousPage) { using (ReportPage page0 = PreparedPages.GetPage(PreparedPages.Count - 1)) { if (page0.PaperWidth == this.page.PaperWidth) { if (page0.UnlimitedWidth == this.page.UnlimitedWidth) { previousPage = true; if (this.page.UnlimitedWidth) { pageNameForRecalc = page0.Name; } } else { previousPage = false; } } else if (page0.UnlimitedWidth && this.page.UnlimitedWidth) { previousPage = true; pageNameForRecalc = page0.Name; } else { previousPage = false; } if (previousPage) { if (page0.PaperHeight == this.page.PaperHeight) { if (page0.UnlimitedHeight == this.page.UnlimitedHeight) { previousPage = true; if (this.page.UnlimitedHeight) { pageNameForRecalc = page0.Name; } } else { previousPage = false; } } else if (page0.UnlimitedHeight && this.page.UnlimitedHeight) { previousPage = true; } else { previousPage = false; } } } } // update CurY or add new page if (previousPage) { CurY = PreparedPages.GetLastY(); } else { PreparedPages.AddPage(page); if (page.StartOnOddPage && (CurPage % 2) == 1) { PreparedPages.AddPage(page); } } // page numbers if (isFirstReportPage) { firstReportPage = CurPage; } if (isFirstReportPage && previousPage) { IncLogicalPageNumber(); } isFirstReportPage = false; OutlineRoot(); AddPageOutline(); // show report title and page header if (previousPage) { ShowBand(page.ReportTitle); } else { if (page.Overlay != null) { ShowBand(page.Overlay); } if (page.TitleBeforeHeader) { ShowBand(page.ReportTitle); ShowPageHeader(); } else { ShowPageHeader(); ShowBand(page.ReportTitle); } } // show column header columnStartY = CurY; ShowBand(page.ColumnHeader); // calculate CurX before starting column event depending on Right to Left or Left to Right layout if (Config.RightToLeft) { CurX = page.Columns.Positions[page.Columns.Positions.Count - 1] * Units.Millimeters; } else { CurX = 0; } // start column event OnStateChanged(page, EngineState.ColumnStarted); ShowProgress(); return(previousPage); }
internal void AddToPreparedPages(BandBase band) { bool isReportSummary = band is ReportSummaryBand; // check if band is service band (e.g. page header/footer/overlay). BandBase mainBand = band; // for child bands, check its parent band. if (band is ChildBand) { mainBand = (band as ChildBand).GetTopParentBand; } bool isPageBand = mainBand is PageHeaderBand || mainBand is PageFooterBand || mainBand is OverlayBand; bool isColumnBand = mainBand is ColumnHeaderBand || mainBand is ColumnFooterBand; // check if we have enough space for a band. bool checkFreeSpace = !isPageBand && !isColumnBand && band.FlagCheckFreeSpace; if (checkFreeSpace && FreeSpace < band.Height) { // we don't have enough space. What should we do? // - if band can break, break it // - if band cannot break, check the band height: // - it's the first row of a band and is bigger than page: break it immediately. // - in other case, add a new page/column and tell the band that it must break next time. if (band.CanBreak || band.FlagMustBreak || (band.AbsRowNo == 1 && band.Height > PageHeight - PageFooterHeight)) { // since we don't show the column footer band in the EndLastPage, do it here. if (isReportSummary) { ShowReprintFooters(); ShowBand(page.ColumnFooter); } BreakBand(band); return; } else { EndColumn(); band.FlagMustBreak = true; AddToPreparedPages(band); band.FlagMustBreak = false; return; } } else { // since we don't show the column footer band in the EndLastPage, do it here. if (isReportSummary) { if ((band as ReportSummaryBand).KeepWithData) { EndKeep(); } ShowReprintFooters(false); ShowBand(page.ColumnFooter); } } // check if we have a child band with FillUnusedSpace flag if (band.Child != null && band.Child.FillUnusedSpace) { // if we reprint a data/group footer, do not include the band height into calculation: // it is already counted in FreeSpace float bandHeight = band.Height; if (band.Repeated) { bandHeight = 0; } while (FreeSpace - bandHeight - band.Child.Height >= 0) { float saveCurY = CurY; ShowBand(band.Child); // nothing was printed, break to avoid an endless loop if (CurY == saveCurY) { break; } } } // adjust the band location if (band is PageFooterBand && !UnlimitedHeight) { CurY = PageHeight - GetBandHeightWithChildren(band); } if (!isPageBand) { band.Left += originX + CurX; } if (band.PrintOnBottom) { CurY = PageHeight - PageFooterHeight - ColumnFooterHeight; // if PrintOnBottom is applied to a band like DataFooter, print it with all its child bands // if PrintOnBottom is applied to a child band, print this band only. if (band is ChildBand) { CurY -= band.Height; } else { CurY -= GetBandHeightWithChildren(band); } } band.Top = CurY; // shift the band and decrease its width when printing hierarchy float saveLeft = band.Left; float saveWidth = band.Width; if (!isPageBand && !isColumnBand) { band.Left += hierarchyIndent; band.Width -= hierarchyIndent; } // add outline AddBandOutline(band); // add bookmarks band.AddBookmarks(); // put the band to prepared pages. Do not put page bands twice // (this may happen when we render a subreport, or append a report to another one). bool bandAdded = true; bool bandAlreadyExists = false; if (isPageBand) { if (band is ChildBand) { bandAlreadyExists = PreparedPages.ContainsBand(band.Name); } else { bandAlreadyExists = PreparedPages.ContainsBand(band.GetType()); } } if (!bandAlreadyExists) { bandAdded = PreparedPages.AddBand(band); } // shift CurY if (bandAdded && !(mainBand is OverlayBand)) { CurY += band.Height; } // set left&width back band.Left = saveLeft; band.Width = saveWidth; }
private void StartFirstPage() { FPage.InitializeComponents(); CurX = 0; CurY = 0; FCurColumn = 0; if (FPage.ResetPageNumber) { ResetLogicalPageNumber(); } bool previousPage = FPage.PrintOnPreviousPage && PreparedPages.Count > 0; // check that previous page has the same size if (previousPage) { using (ReportPage page = PreparedPages.GetPage(PreparedPages.Count - 1)) { if (page.PaperWidth != FPage.PaperWidth || page.PaperHeight != FPage.PaperHeight) { previousPage = false; } } } // update CurY or add new page if (previousPage) { CurY = PreparedPages.GetLastY(); } else { PreparedPages.AddPage(FPage); if (FPage.StartOnOddPage && (CurPage % 2) == 1) { PreparedPages.AddPage(FPage); } } // page numbers if (FIsFirstReportPage) { FFirstReportPage = CurPage; } if (FIsFirstReportPage && previousPage) { IncLogicalPageNumber(); } FIsFirstReportPage = false; OutlineRoot(); AddPageOutline(); // show report title and page header if (previousPage) { ShowBand(FPage.ReportTitle); } else { if (FPage.Overlay != null) { ShowBand(FPage.Overlay); } if (FPage.TitleBeforeHeader) { ShowBand(FPage.ReportTitle); ShowPageHeader(); } else { ShowPageHeader(); ShowBand(FPage.ReportTitle); } } // show column header FColumnStartY = CurY; ShowBand(FPage.ColumnHeader); // start column event OnStateChanged(FPage, EngineState.ColumnStarted); ShowProgress(); }
private void CutObjects() { FKeepDeltaY = CurY - FKeepCurY; PreparedPages.CutObjects(FKeepPosition); CurY = FKeepCurY; }
private void GeneratePagesAcrossThenDown() { ReportEngine engine = Report.Engine; PreparedPages preparedPages = Report.PreparedPages; preparedPages.CanUploadToCache = false; preparedPages.AddPageAction = AddPageAction.WriteOver; List <Rectangle> spans = GetSpanList(); int startRow = 0; bool addNewPage = false; float freeSpace = engine.FreeSpace; Top = 0; while (startRow < Rows.Count) { if (addNewPage) { engine.StartNewPage(); freeSpace = engine.FreeSpace; } int startColumn = 0; int rowsFit = GetRowsFit(startRow, freeSpace); if (startRow == 0 && engine.IsKeeping && rowsFit < RowCount && isFirstRow && engine.KeepCurY > 0) { engine.EndColumn(); freeSpace = engine.FreeSpace; rowsFit = GetRowsFit(startRow, freeSpace); } // avoid the infinite loop if there is not enough space for one row if (startRow > 0 && rowsFit == 0) { rowsFit = 1; } int saveCurPage = engine.CurPage; float saveLeft = Left; float saveCurY = engine.CurY; float curY = engine.CurY; if (rowsFit != 0) { while (startColumn < Columns.Count) { int columnsFit = GetColumnsFit(startColumn, engine.PageWidth - Left); // avoid the infinite loop if there is not enough space for one column if (startColumn > 0 && columnsFit == 0) { columnsFit = 1; } engine.CurY = saveCurY; curY = GeneratePage(startColumn, startRow, columnsFit, rowsFit, new RectangleF(0, 0, engine.PageWidth, CanBreak ? freeSpace : Height), spans) + saveCurY; Left = 0; startColumn += columnsFit; if (startColumn < Columns.Count) { // if we have something to print, start a new page engine.StartNewPage(); } else if (engine.CurPage > saveCurPage) { // finish the last printed page in case it is not the start page engine.EndPage(false); } if (Report.Aborted) { break; } } } startRow += rowsFit; Left = saveLeft; engine.CurPage = saveCurPage; engine.CurY = curY; preparedPages.AddPageAction = AddPageAction.Add; addNewPage = true; if (Report.Aborted) { break; } } }
private TableLayoutInfo GeneratePagesDownThenAcross() { ReportEngine engine = Report.Engine; PreparedPages preparedPages = Report.PreparedPages; preparedPages.CanUploadToCache = false; TableLayoutInfo info = new TableLayoutInfo(); info.startPage = engine.CurPage; List <Rectangle> spans = GetSpanList(); int startColumn = 0; bool addNewPage = false; float saveCurY = engine.CurY; float lastCurY = 0; int lastPage = 0; Top = 0; while (startColumn < Columns.Count) { if (addNewPage) { engine.StartNewPage(); } int startRow = 0; int columnsFit = GetColumnsFit(startColumn, engine.PageWidth - Left); // avoid the infinite loop if there is not enough space for one column if (startColumn > 0 && columnsFit == 0) { columnsFit = 1; } engine.CurY = saveCurY; info.tableSize.Width++; info.tableSize.Height = 0; if (columnsFit > 0) { while (startRow < Rows.Count) { int rowsFit = GetRowsFit(startRow, engine.FreeSpace); if (startRow == 0 && engine.IsKeeping && rowsFit < RowCount && isFirstRow && engine.KeepCurY > 0) { engine.EndColumn(); rowsFit = GetRowsFit(startRow, engine.FreeSpace); } // avoid the infinite loop if there is not enough space for one row if (startRow > 0 && rowsFit == 0) { rowsFit = 1; } engine.CurY += GeneratePage(startColumn, startRow, columnsFit, rowsFit, new RectangleF(0, 0, engine.PageWidth, engine.FreeSpace), spans); info.tableSize.Height++; startRow += rowsFit; if (startRow < Rows.Count) { // if we have something to print, start a new page engine.StartNewPage(); } else if (startColumn > 0) { // finish the last printed page in case it is not a start page engine.EndPage(false); } if (Report.Aborted) { break; } } } info.startX = Left + GetColumnsWidth(startColumn, columnsFit); startColumn += columnsFit; Left = 0; preparedPages.AddPageAction = AddPageAction.Add; addNewPage = true; if (lastPage == 0) { lastPage = engine.CurPage; lastCurY = engine.CurY; } if (Report.Aborted) { break; } } engine.CurPage = lastPage; engine.CurY = lastCurY; return(info); }