Пример #1
0
        internal void GeneratePages(object sender, EventArgs e)
        {
            isFirstRow = false;
            if (Skip)
            {
                Skip = false;
                return;
            }


            // check if band contains several tables
            if (sender is BandBase)
            {
                BandBase senderBand = sender as BandBase;
                isFirstRow = senderBand.IsFirstRow;
                SortedList <float, TableBase> tables = new SortedList <float, TableBase>();
                foreach (Base obj in senderBand.Objects)
                {
                    TableBase table = obj as TableBase;
                    if (table != null && table.ResultTable != null)
                    {
                        try
                        {
                            tables.Add(table.Left, table);
                        }
                        catch (ArgumentException)
                        {
                            throw new ArgumentException(Res.Get("Messages,MatrixLayoutError"));
                        }
                    }
                }

                // render tables side-by-side
                if (tables.Count > 1)
                {
                    ReportEngine    engine = Report.Engine;
                    TableLayoutInfo info   = new TableLayoutInfo();
                    info.startPage = engine.CurPage;
                    info.tableSize = new Size(1, 1);
                    info.startX    = tables.Values[0].Left;

                    int   startPage = info.startPage;
                    float saveCurY  = engine.CurY;
                    int   maxPage   = 0;
                    float maxCurY   = 0;

                    for (int i = 0; i < tables.Count; i++)
                    {
                        TableBase table = tables.Values[i];

                        // do not allow table to render itself in the band.AfterPrint event
                        table.ResultTable.Skip = true;
                        // render using the down-then-across mode
                        table.Layout = TableLayout.DownThenAcross;

                        engine.CurPage = info.startPage + (info.tableSize.Width - 1) * info.tableSize.Height;
                        engine.CurY    = saveCurY;
                        float addLeft = 0;
                        if (i > 0)
                        {
                            addLeft = table.Left - tables.Values[i - 1].Right;
                        }
                        table.ResultTable.Left = info.startX + addLeft;

                        // calculate cells' bounds
                        table.ResultTable.CalcBounds();
                        // generate pages
                        Report.PreparedPages.AddPageAction = AddPageAction.WriteOver;
                        info = table.ResultTable.GeneratePagesDownThenAcross();

                        if (engine.CurPage > maxPage)
                        {
                            maxPage = engine.CurPage;
                            maxCurY = engine.CurY;
                        }
                        else if (engine.CurPage == maxPage && engine.CurY > maxCurY)
                        {
                            maxCurY = engine.CurY;
                        }
                    }

                    engine.CurPage = maxPage;
                    engine.CurY    = maxCurY;

                    Skip = false;
                    return;
                }
            }

            // calculate cells' bounds
            CalcBounds();
            // manage duplicates
            ProcessDuplicates();

            if (Report.Engine.UnlimitedHeight || Report.Engine.UnlimitedWidth)
            {
                if (!Report.Engine.UnlimitedWidth)
                {
                    GeneratePagesWrapped();
                }
                else if (!Report.Engine.UnlimitedHeight)
                {
                    GeneratePagesDownThenAcross();
                }
                else
                {
                    GeneratePagesAcrossThenDown();
                }
            }
            else if (Layout == TableLayout.AcrossThenDown)
            {
                GeneratePagesAcrossThenDown();
            }
            else if (Layout == TableLayout.DownThenAcross)
            {
                GeneratePagesDownThenAcross();
            }
            else
            {
                GeneratePagesWrapped();
            }
        }
Пример #2
0
        /// <inheritdoc/>
        public override bool Break(BreakableComponent breakTo)
        {
            if (Rows.Count == 0)
            {
                return(true);
            }
            if (Height < Rows[0].Height && !Rows[0].CanBreak)
            {
                return(false);
            }
            TableBase tableTo = breakTo as TableBase;

            if (tableTo == null)
            {
                return(true);
            }

            // find the break row index
            int   breakRowIndex    = 0;
            int   breakRowIndexAdd = 0;
            bool  rowBroken        = false;
            float rowsHeight       = 0;

            while (breakRowIndex < Rows.Count)
            {
                rowsHeight += Rows[breakRowIndex].Height;
                if (rowsHeight > Height)
                {
                    float breakRowHeight = Rows[breakRowIndex].Height - (rowsHeight - Height);
                    if (CanBreakRow(breakRowIndex, breakRowHeight))
                    {
                        BreakRow(tableTo, breakRowIndex, breakRowHeight, rowsHeight - Height);
                        breakRowIndexAdd = 1;
                        rowBroken        = true;
                    }
                    break;
                }

                breakRowIndex++;
            }

            // get the span list
            List <Rectangle> spans = GetSpanList();

            // break the spans
            foreach (Rectangle span in spans)
            {
                if (span.Top < breakRowIndex + breakRowIndexAdd && span.Bottom > breakRowIndex)
                {
                    TableCell cell   = this[span.Left, span.Top];
                    TableCell cellTo = tableTo[span.Left, span.Top];

                    // update cell spans
                    cell.RowSpan   = breakRowIndex + breakRowIndexAdd - span.Top;
                    cellTo.RowSpan = span.Bottom - breakRowIndex;

                    // break the cell
                    if (!rowBroken && !cell.Break(cellTo))
                    {
                        cell.Text = "";
                    }

                    // set the top span cell to the correct place
                    tableTo[span.Left, span.Top]      = new TableCell();
                    tableTo[span.Left, breakRowIndex] = cellTo;
                }
            }

            // remove unused rows from source (this table)
            while (breakRowIndex + breakRowIndexAdd < Rows.Count)
            {
                this.Rows.RemoveAt(Rows.Count - 1);
            }

            // remove unused rows from copy (tableTo)
            for (int i = 0; i < breakRowIndex; i++)
            {
                tableTo.Rows.RemoveAt(0);
            }

            return(true);
        }
Пример #3
0
        internal void GeneratePages(object sender, EventArgs e)
        {
            if (Skip)
            {
                Skip = false;
                return;
            }

            // check if band contains several tables
            if (sender is BandBase)
            {
                SortedList <float, TableBase> tables = new SortedList <float, TableBase>();
                foreach (Base obj in (sender as BandBase).Objects)
                {
                    TableBase table = obj as TableBase;
                    if (table != null && table.ResultTable != null)
                    {
                        tables.Add(table.Left, table);
                    }
                }

                // render tables side-by-side
                if (tables.Count > 1)
                {
                    ReportEngine    engine = Report.Engine;
                    TableLayoutInfo info   = new TableLayoutInfo();
                    info.StartPage = engine.CurPage;
                    info.TableSize = new Size(1, 1);
                    info.StartX    = tables.Values[0].Left;

                    int   firstTableHeight = 0;
                    int   startPage        = info.StartPage;
                    float firstTableCurY   = 0;
                    float saveCurY         = engine.CurY;

                    for (int i = 0; i < tables.Count; i++)
                    {
                        TableBase table = tables.Values[i];

                        // do not allow table to render itself in the band.AfterPrint event
                        table.ResultTable.Skip = true;
                        // render using the down-then-across mode
                        table.Layout = TableLayout.DownThenAcross;

                        engine.CurPage = info.StartPage + (info.TableSize.Width - 1) * info.TableSize.Height;
                        engine.CurY    = saveCurY;
                        float addLeft = 0;
                        if (i > 0)
                        {
                            addLeft = table.Left - tables.Values[i - 1].Right;
                        }
                        table.ResultTable.Left = info.StartX + addLeft;

                        // calculate cells' bounds
                        table.ResultTable.CalcBounds();
                        // generate pages
                        Report.PreparedPages.AddPageAction = AddPageAction.WriteOver;
                        info = table.ResultTable.GeneratePagesDownThenAcross();

                        if (i == 0)
                        {
                            firstTableHeight = info.TableSize.Height;
                            firstTableCurY   = engine.CurY;
                        }
                    }

                    engine.CurPage = startPage + firstTableHeight - 1;
                    engine.CurY    = firstTableCurY;

                    Skip = false;
                    return;
                }
            }

            // calculate cells' bounds
            CalcBounds();

            if (Layout == TableLayout.AcrossThenDown)
            {
                GeneratePagesAcrossThenDown();
            }
            else if (Layout == TableLayout.DownThenAcross)
            {
                GeneratePagesDownThenAcross();
            }
            else
            {
                GeneratePagesWrapped();
            }
        }
Пример #4
0
        /// <inheritdoc/>
        public override bool Break(BreakableComponent breakTo)
        {
            if (Rows.Count == 0)
            {
                return(true);
            }
            if (Height < Rows[0].Height)
            {
                return(false);
            }
            TableBase tableTo = breakTo as TableBase;

            if (tableTo == null)
            {
                return(true);
            }

            // get the span list
            List <Rectangle> spans = GetSpanList();

            // find the break row index
            int   breakRowIndex = 0;
            float rowsHeight    = 0;

            while (breakRowIndex < Rows.Count && rowsHeight + Rows[breakRowIndex].Height < Height)
            {
                rowsHeight += Rows[breakRowIndex].Height;
                breakRowIndex++;
            }

            // break the spans
            foreach (Rectangle span in spans)
            {
                if (span.Top < breakRowIndex && span.Bottom > breakRowIndex)
                {
                    TableCell cell   = this[span.Left, span.Top];
                    TableCell cellTo = tableTo[span.Left, span.Top];

                    // update cell spans
                    cell.RowSpan   = breakRowIndex - span.Top;
                    cellTo.RowSpan = span.Bottom - breakRowIndex;

                    // break the cell
                    if (!cell.Break(cellTo))
                    {
                        cell.Text = "";
                    }
                    tableTo[span.Left, span.Top]      = new TableCell();
                    tableTo[span.Left, breakRowIndex] = cellTo;
                }
            }

            // delete last rows until all rows fit
            while (breakRowIndex < Rows.Count)
            {
                Rows.RemoveAt(Rows.Count - 1);
            }

            // delete first rows of the breakTo
            for (int i = 0; i < breakRowIndex; i++)
            {
                tableTo.Rows.RemoveAt(0);
            }

            return(true);
        }
Пример #5
0
 public TableClipboard(TableBase table)
 {
     FTable   = table;
     FColumns = new List <TableColumn>();
     FRows    = new List <TableRow>();
 }