Inheritance: iTextSharp.text.Rectangle
        /// <summary>
        /// Updates the table row additions in the underlying table object
        /// </summary>

        private void updateRowAdditionsInternal()
        {
            // correct table : fill empty cells/ parse table in table
            var     prevRows    = Rows;
            var     rowNumber   = 0;
            var     groupNumber = 0;
            bool    groupChange;
            var     firstDataRow = Table.LastHeaderRow + 1;
            Cell    cell;
            PdfCell currentCell;
            var     newCells = new ArrayList();
            var     rows     = Table.Size + 1;
            var     offsets  = new float[rows];

            for (var i = 0; i < rows; i++)
            {
                offsets[i] = Bottom;
            }

            // loop over all the rows
            foreach (Row row in Table)
            {
                groupChange = false;
                if (row.IsEmpty())
                {
                    if (rowNumber < rows - 1 && offsets[rowNumber + 1] > offsets[rowNumber])
                    {
                        offsets[rowNumber + 1] = offsets[rowNumber];
                    }
                }
                else
                {
                    for (var i = 0; i < row.Columns; i++)
                    {
                        cell = (Cell)row.GetCell(i);
                        if (cell != null)
                        {
                            currentCell = new PdfCell(cell, rowNumber + prevRows, Positions[i], Positions[i + cell.Colspan], offsets[rowNumber], Cellspacing, Cellpadding);
                            if (rowNumber < firstDataRow)
                            {
                                currentCell.SetHeader();
                                HeaderCells.Add(currentCell);
                                if (!Table.NotAddedYet)
                                {
                                    continue;
                                }
                            }
                            try
                            {
                                if (offsets[rowNumber] - currentCell.Height - Cellpadding < offsets[rowNumber + currentCell.Rowspan])
                                {
                                    offsets[rowNumber + currentCell.Rowspan] = offsets[rowNumber] - currentCell.Height - Cellpadding;
                                }
                            }
                            catch (ArgumentOutOfRangeException)
                            {
                                if (offsets[rowNumber] - currentCell.Height < offsets[rows - 1])
                                {
                                    offsets[rows - 1] = offsets[rowNumber] - currentCell.Height;
                                }
                            }
                            currentCell.GroupNumber = groupNumber;
                            groupChange            |= cell.GroupChange;
                            newCells.Add(currentCell);
                        }
                    }
                }
                rowNumber++;
                if (groupChange)
                {
                    groupNumber++;
                }
            }

            // loop over all the cells
            var n = newCells.Count;

            for (var i = 0; i < n; i++)
            {
                currentCell = (PdfCell)newCells[i];
                try
                {
                    currentCell.Bottom = offsets[currentCell.Rownumber - prevRows + currentCell.Rowspan];
                }
                catch (ArgumentOutOfRangeException)
                {
                    currentCell.Bottom = offsets[rows - 1];
                }
            }
            Cells.AddRange(newCells);
            Bottom = offsets[rows - 1];
        }
Beispiel #2
0
        // constructors

        /**
         * Constructs a <CODE>PdfTable</CODE>-object.
         *
         * @param	table	a <CODE>Table</CODE>
         * @param	left	the left border on the page
         * @param	right	the right border on the page
         * @param	top		the start position of the top of the table
         */

        internal PdfTable(Table table, float left, float right, float top) : base(left, top, right, top)
        {
            // copying the attributes from class Table
            Border           = table.Border;
            BorderWidth      = table.BorderWidth;
            BorderColor      = table.BorderColor;
            BackgroundColor  = table.BackgroundColor;
            GrayFill         = table.GrayFill;
            this.columns     = table.Columns;
            this.cellpadding = table.Cellpadding;
            this.cellspacing = table.Cellspacing;
            float[] positions = table.getWidths(left, right - left);

            // initialisation of some parameters
            Left  = positions[0];
            Right = positions[positions.Length - 1];

            //Row row;
            int     rowNumber    = 0;
            int     firstDataRow = table.firstDataRow();
            Cell    cell;
            PdfCell currentCell;

            headercells = new ArrayList();
            cells       = new ArrayList();
            int rows = table.Size + 1;

            float[] offsets = new float[rows];
            for (int i = 0; i < rows; i++)
            {
                offsets[i] = top;
            }

            // loop over all the rows
            foreach (Row row in table)
            {
                if (row.isEmpty())
                {
                    if (rowNumber < rows - 1 && offsets[rowNumber + 1] > offsets[rowNumber])
                    {
                        offsets[rowNumber + 1] = offsets[rowNumber];
                    }
                }
                else
                {
                    for (int i = 0; i < row.Columns; i++)
                    {
                        cell = (Cell)row.getCell(i);
                        if (cell != null)
                        {
                            currentCell = new PdfCell(cell, rowNumber, positions[i], positions[i + cell.Colspan], offsets[rowNumber], cellspacing, cellpadding);
                            try {
                                if (offsets[rowNumber] - currentCell.Height - cellpadding < offsets[rowNumber + currentCell.Rowspan])
                                {
                                    offsets[rowNumber + currentCell.Rowspan] = offsets[rowNumber] - currentCell.Height - cellpadding;
                                }
                            }
                            catch (Exception aioobe) {
                                aioobe.GetType();
                                if (offsets[rowNumber] - currentCell.Height < offsets[rows - 1])
                                {
                                    offsets[rows - 1] = offsets[rowNumber] - currentCell.Height;
                                }
                            }
                            if (rowNumber < firstDataRow)
                            {
                                currentCell.Header = true;
                                headercells.Add(currentCell);
                            }
                            cells.Add(currentCell);
                        }
                    }
                }
                rowNumber++;
            }

            // loop over all the cells
            int n = cells.Count;

            for (int i = 0; i < n; i++)
            {
                currentCell = (PdfCell)cells[i];
                try {
                    currentCell.Bottom = offsets[currentCell.Rownumber + currentCell.Rowspan];
                }
                catch (Exception aioobe) {
                    aioobe.GetType();
                    currentCell.Bottom = offsets[rows - 1];
                }
            }
            Bottom = offsets[rows - 1];
        }
Beispiel #3
0
        /**
        * Updates the table row additions in the underlying table object
        */
        private void UpdateRowAdditionsInternal()
        {
            // correct table : fill empty cells/ parse table in table
            int prevRows = Rows;
            int rowNumber = 0;
            int groupNumber = 0;
            bool groupChange;
            int firstDataRow = table.FirstDataRow;
            Cell cell;
            PdfCell currentCell;
            ArrayList newCells = new ArrayList();
            int rows = table.Size + 1;
            float[] offsets = new float[rows];
            for (int i = 0; i < rows; i++) {
                offsets[i] = Bottom;
            }

            // loop over all the rows
            foreach (Row row in table) {
                groupChange = false;
                if (row.IsEmpty()) {
                    if (rowNumber < rows - 1 && offsets[rowNumber + 1] > offsets[rowNumber]) offsets[rowNumber + 1] = offsets[rowNumber];
                }
                else {
                    for (int i = 0; i < row.Columns; i++) {
                        cell = (Cell) row.GetCell(i);
                        if (cell != null) {
                            currentCell = new PdfCell(cell, rowNumber+prevRows, positions[i], positions[i + cell.Colspan], offsets[rowNumber], Cellspacing, Cellpadding);
                            try {
                                if (offsets[rowNumber] - currentCell.Height - Cellpadding < offsets[rowNumber + currentCell.Rowspan]) {
                                    offsets[rowNumber + currentCell.Rowspan] = offsets[rowNumber] - currentCell.Height - Cellpadding;
                                }
                            }
                            catch (ArgumentOutOfRangeException) {
                                if (offsets[rowNumber] - currentCell.Height < offsets[rows - 1]) {
                                    offsets[rows - 1] = offsets[rowNumber] - currentCell.Height;
                                }
                            }
                            if (rowNumber < firstDataRow) {
                                currentCell.SetHeader();
                                headercells.Add(currentCell);
                            }
                            currentCell.GroupNumber = groupNumber;
                            groupChange |= cell.GroupChange;
                            newCells.Add(currentCell);
                        }
                    }
                }
                rowNumber++;
                if ( groupChange ) groupNumber++;
            }

            // loop over all the cells
            int n = newCells.Count;
            for (int i = 0; i < n; i++) {
                currentCell = (PdfCell) newCells[i];
                try {
                    currentCell.Bottom = offsets[currentCell.Rownumber-prevRows + currentCell.Rowspan];
                }
                catch (ArgumentOutOfRangeException) {
                    currentCell.Bottom = offsets[rows - 1];
                }
            }
            cells.AddRange(newCells);
            Bottom = offsets[rows - 1];
        }
Beispiel #4
0
 public int NumCellRendered(PdfCell cell)
 {
     object i = pageMap[cell];
     if (i == null) {
         i = 0;
     }
     return (int)i;
 }
Beispiel #5
0
            public bool IsCellRenderedOnPage(PdfCell cell, int pageNumber)
            {
                Hashtable seti = (Hashtable) pageMap[pageNumber];

                if (seti != null) {
                    return seti.ContainsKey(cell);
                }

                return false;
            }
Beispiel #6
0
 /**
 * Looks at the current rowspan.
 * @param c
 * @return the current rowspan
 */
 public int CurrentRowspan(PdfCell c)
 {
     object i = rowspanMap[c];
     if (i == null) {
         return c.Rowspan;
     } else {
         return (int)i;
     }
 }
Beispiel #7
0
            /**
            * Consumes the rowspan
            * @param c
            * @return a rowspan.
            */
            public int ConsumeRowspan(PdfCell c)
            {
                if (c.Rowspan == 1) {
                    return 1;
                }

                object i = rowspanMap[c];
                if (i == null) {
                    i = c.Rowspan;
                }

                i = (int)i - 1;
                rowspanMap[c] = i;

                if ((int)i < 1) {
                    return 1;
                }
                return (int)i;
            }
Beispiel #8
0
            public int CellRendered(PdfCell cell, int pageNumber)
            {
                object i = pageMap[cell];
                if (i == null) {
                    i = 1;
                } else {
                    i = (int)i + 1;
                }
                pageMap[cell] = i;

                Hashtable seti = (Hashtable)pageMap[pageNumber];

                if (seti == null) {
                    seti = new Hashtable();
                    pageMap[pageNumber] = seti;
                }

                seti[cell] = null;

                return (int)i;
            }