Esempio n. 1
0
        public void TestSortColumns()
        {
            //CT_Worksheet worksheet = new CT_Worksheet();
            //ColumnHelper helper = new ColumnHelper(worksheet);

            CT_Cols cols1 = new CT_Cols();
            CT_Col  col1  = cols1.AddNewCol();

            col1.min    = (1);
            col1.max    = (1);
            col1.width  = (88);
            col1.hidden = (true);
            CT_Col col2 = cols1.AddNewCol();

            col2.min = (2);
            col2.max = (3);
            CT_Col col3 = cols1.AddNewCol();

            col3.min = (13);
            col3.max = (16750);
            Assert.AreEqual(3, cols1.sizeOfColArray());
            CT_Col col4 = cols1.AddNewCol();

            col4.min = (8);
            col4.max = (11);
            Assert.AreEqual(4, cols1.sizeOfColArray());
            CT_Col col5 = cols1.AddNewCol();

            col5.min = (4);
            col5.max = (5);
            Assert.AreEqual(5, cols1.sizeOfColArray());
            CT_Col col6 = cols1.AddNewCol();

            col6.min    = (8);
            col6.max    = (9);
            col6.hidden = (true);
            CT_Col col7 = cols1.AddNewCol();

            col7.min   = (6);
            col7.max   = (8);
            col7.width = (17.0);
            CT_Col col8 = cols1.AddNewCol();

            col8.min = (25);
            col8.max = (27);
            CT_Col col9 = cols1.AddNewCol();

            col9.min = (20);
            col9.max = (30);
            Assert.AreEqual(9, cols1.sizeOfColArray());
            Assert.AreEqual(20u, cols1.GetColArray(8).min);
            Assert.AreEqual(30u, cols1.GetColArray(8).max);
            ColumnHelper.SortColumns(cols1);
            Assert.AreEqual(9, cols1.sizeOfColArray());
            Assert.AreEqual(25u, cols1.GetColArray(8).min);
            Assert.AreEqual(27u, cols1.GetColArray(8).max);
        }
Esempio n. 2
0
        public CT_Cols AddCleanColIntoCols(CT_Cols cols, CT_Col col)
        {
            bool flag = false;

            for (int index = 0; index < cols.sizeOfColArray(); ++index)
            {
                CT_Col colArray = cols.GetColArray(index);
                long[] range1   = new long[2] {
                    (long)colArray.min, (long)colArray.max
                };
                long[] range2 = new long[2] {
                    (long)col.min, (long)col.max
                };
                long[] overlappingRange = NumericRanges.GetOverlappingRange(range1, range2);
                int    overlappingType  = NumericRanges.GetOverlappingType(range1, range2);
                if (overlappingType == 0)
                {
                    colArray.max = (uint)((ulong)overlappingRange[0] - 1UL);
                    this.insertCol(cols, overlappingRange[0], overlappingRange[1], new CT_Col[2]
                    {
                        colArray,
                        col
                    });
                    int num = index + 1;
                    this.insertCol(cols, overlappingRange[1] + 1L, (long)col.max, new CT_Col[1]
                    {
                        col
                    });
                    index = num + 1;
                }
                else if (overlappingType == 1)
                {
                    colArray.min = (uint)((ulong)overlappingRange[1] + 1UL);
                    this.insertCol(cols, overlappingRange[0], overlappingRange[1], new CT_Col[2]
                    {
                        colArray,
                        col
                    });
                    int num = index + 1;
                    this.insertCol(cols, (long)col.min, overlappingRange[0] - 1L, new CT_Col[1]
                    {
                        col
                    });
                    index = num + 1;
                }
                else if (overlappingType == 3)
                {
                    this.SetColumnAttributes(col, colArray);
                    if ((int)col.min != (int)colArray.min)
                    {
                        this.insertCol(cols, (long)col.min, (long)(colArray.min - 1U), new CT_Col[1]
                        {
                            col
                        });
                        ++index;
                    }
                    if ((int)col.max != (int)colArray.max)
                    {
                        this.insertCol(cols, (long)(colArray.max + 1U), (long)col.max, new CT_Col[1]
                        {
                            col
                        });
                        ++index;
                    }
                }
                else if (overlappingType == 2)
                {
                    if ((int)col.min != (int)colArray.min)
                    {
                        this.insertCol(cols, (long)colArray.min, (long)(col.min - 1U), new CT_Col[1]
                        {
                            colArray
                        });
                        ++index;
                    }
                    if ((int)col.max != (int)colArray.max)
                    {
                        this.insertCol(cols, (long)(col.max + 1U), (long)colArray.max, new CT_Col[1]
                        {
                            colArray
                        });
                        ++index;
                    }
                    colArray.min = (uint)overlappingRange[0];
                    colArray.max = (uint)overlappingRange[1];
                    this.SetColumnAttributes(col, colArray);
                }
                if (overlappingType != -1)
                {
                    flag = true;
                }
            }
            if (!flag)
            {
                this.CloneCol(cols, col);
            }
            ColumnHelper.SortColumns(cols);
            return(cols);
        }