Example #1
0
        /// <summary>
        /// Builds a model of the rows within this entity.
        /// </summary>
        internal override RowOrColumnsModel BuildRowsModel()
        {
            var rowsModel = new RowOrColumnsModel(true);

            // Consider all elements in the container on a column-by-column basis.
            for (uint colIdx = 1; colIdx <= this.mapColumnCount; colIdx++)
            {
                // Create a RowsModel for the column
                var columnRowsModel = new RowOrColumnsModel(true);

                for (uint rowIdx = 1; rowIdx <= this.mapRowCount; rowIdx++)
                {
                    // Use System.Drawing.Point as key as it has a very efficient hashing algorithm
                    var cellListKey = new System.Drawing.Point((int)colIdx, (int)rowIdx);
                    if (this.cells.ContainsKey(cellListKey))
                    {
                        ExcelMapCoOrdinate element          = this.cells[cellListKey];
                        RowOrColumnsModel  elementRowsModel = element.BuildRowsModel();

                        columnRowsModel.AppendModel(elementRowsModel);
                    }
                }

                // Merge the columns model generated for the row with the model for the container.
                rowsModel.MergeModel(columnRowsModel);

                // Add this container into the column (if not already there)
                RowOrColumnInfo rowInfo = rowsModel.First;
                while (rowInfo != null)
                {
                    rowInfo.AddMap(this);
                    rowInfo = rowInfo.Next;
                }
            }

            return(rowsModel);
        }