//YK: GetXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support public static void SortColumns(CT_Cols newCols) { List<CT_Col> colArray = newCols.GetColArray(); colArray.Sort(new CTColComparator()); newCols.SetColArray(colArray); }
private bool columnExists(CT_Cols cols, long min, long max) { for (int i = 0; i < cols.sizeOfColArray(); i++) { if (cols.GetColArray(i).min == min && cols.GetColArray(i).max == max) { return true; } } return false; }
public int GetIndexOfColumn(CT_Cols cols, CT_Col col) { for (int i = 0; i < cols.sizeOfColArray(); i++) { if (cols.GetColArray(i).min == col.min && cols.GetColArray(i).max == col.max) { return i; } } return -1; }
private bool columnExists1Based(CT_Cols cols, long index1) { for (int i = 0; i < cols.sizeOfColArray(); i++) { if (cols.GetColArray(i).min == index1) { return true; } } return false; }
public CT_Cols AddCleanColIntoCols(CT_Cols cols, CT_Col col) { bool colOverlaps = false; for (int i = 0; i < cols.sizeOfColArray(); i++) { CT_Col ithCol = cols.GetColArray(i); long[] range1 = { ithCol.min, ithCol.max }; long[] range2 = { col.min, col.max }; long[] overlappingRange = NumericRanges.GetOverlappingRange(range1, range2); int overlappingType = NumericRanges.GetOverlappingType(range1, range2); // different behavior required for each of the 4 different // overlapping types if (overlappingType == NumericRanges.OVERLAPS_1_MINOR) { ithCol.max = (uint)(overlappingRange[0] - 1); CT_Col rangeCol = insertCol(cols, overlappingRange[0], overlappingRange[1], new CT_Col[] { ithCol, col }); i++; CT_Col newCol = insertCol(cols, (overlappingRange[1] + 1), col .max, new CT_Col[] { col }); i++; } else if (overlappingType == NumericRanges.OVERLAPS_2_MINOR) { ithCol.min = (uint)(overlappingRange[1] + 1); CT_Col rangeCol = insertCol(cols, overlappingRange[0], overlappingRange[1], new CT_Col[] { ithCol, col }); i++; CT_Col newCol = insertCol(cols, col.min, (overlappingRange[0] - 1), new CT_Col[] { col }); i++; } else if (overlappingType == NumericRanges.OVERLAPS_2_WRAPS) { SetColumnAttributes(col, ithCol); if (col.min != ithCol.min) { CT_Col newColBefore = insertCol(cols, col.min, (ithCol .min - 1), new CT_Col[] { col }); i++; } if (col.max != ithCol.max) { CT_Col newColAfter = insertCol(cols, (ithCol.max + 1), col.max, new CT_Col[] { col }); i++; } } else if (overlappingType == NumericRanges.OVERLAPS_1_WRAPS) { if (col.min != ithCol.min) { CT_Col newColBefore = insertCol(cols, ithCol.min, (col .min - 1), new CT_Col[] { ithCol }); i++; } if (col.max != ithCol.max) { CT_Col newColAfter = insertCol(cols, (col.max + 1), ithCol.max, new CT_Col[] { ithCol }); i++; } ithCol.min = (uint)(overlappingRange[0]); ithCol.max = (uint)(overlappingRange[1]); SetColumnAttributes(col, ithCol); } if (overlappingType != NumericRanges.NO_OVERLAPS) { colOverlaps = true; } } if (!colOverlaps) { CT_Col newCol = CloneCol(cols, col); } SortColumns(cols); return cols; }
public void TestAddCleanColIntoCols() { 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 = (9); Assert.AreEqual(4, cols1.sizeOfColArray()); CT_Col col5 = new CT_Col(); col5.min = (4); col5.max = (5); helper.AddCleanColIntoCols(cols1, col5); Assert.AreEqual(5, cols1.sizeOfColArray()); CT_Col col6 = new CT_Col(); col6.min = (8); col6.max = (11); col6.hidden = (true); helper.AddCleanColIntoCols(cols1, col6); Assert.AreEqual(6, cols1.sizeOfColArray()); CT_Col col7 = new CT_Col(); col7.min = (6); col7.max = (8); col7.width = (17.0); helper.AddCleanColIntoCols(cols1, col7); Assert.AreEqual(8, cols1.sizeOfColArray()); CT_Col col8 = new CT_Col(); col8.min = (20); col8.max = (30); helper.AddCleanColIntoCols(cols1, col8); Assert.AreEqual(10, cols1.sizeOfColArray()); CT_Col col9 = new CT_Col(); col9.min = (25); col9.max = (27); helper.AddCleanColIntoCols(cols1, col9); // TODO - assert something interesting Assert.AreEqual(12, cols1.col.Count); Assert.AreEqual(1u, cols1.GetColArray(0).min); Assert.AreEqual(16750u, cols1.GetColArray(11).max); }
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); }
/** * Do not leave the width attribute undefined (see #52186). */ private void SetColWidthAttribute(CT_Cols ctCols) { foreach (CT_Col col in ctCols.GetColArray()) { if (!col.IsSetWidth()) { col.width = (DefaultColumnWidth); col.customWidth = (false); } } }