public override Object Clone() { ColumnInfoRecord rec = new ColumnInfoRecord(); rec._first_col = _first_col; rec._last_col = _last_col; rec._col_width = _col_width; rec._xf_index = _xf_index; rec._options = _options; rec.field_6_reserved = field_6_reserved; return(rec); }
/** * @return true if the format, options and column width match */ public bool FormatMatches(ColumnInfoRecord other) { if (_xf_index != other._xf_index) { return(false); } if (_options != other._options) { return(false); } if (_col_width != other._col_width) { return(false); } return(true); }
/** * Sets all non null fields into the <c>ci</c> parameter. */ private void SetColumnInfoFields(ColumnInfoRecord ci, short xfStyle, short width, int level, bool hidden, bool collapsed) { ci.XFIndex = (xfStyle); ci.ColumnWidth = (width); ci.OutlineLevel = (short)level; ci.IsHidden = (hidden); ci.IsCollapsed = (collapsed); }
private ColumnInfoRecord CopyColInfo(ColumnInfoRecord ci) { return (ColumnInfoRecord)ci.Clone(); }
/// <summary> /// Sets the column. /// </summary> /// <param name="targetColumnIx">The target column ix.</param> /// <param name="xfIndex">Index of the xf.</param> /// <param name="width">The width.</param> /// <param name="level">The level.</param> /// <param name="hidden">The hidden.</param> /// <param name="collapsed">The collapsed.</param> public void SetColumn(int targetColumnIx, short? xfIndex, int? width, int? level, bool? hidden, bool? collapsed) { ColumnInfoRecord ci = null; int k = 0; for (k = 0; k < records.Count; k++) { ColumnInfoRecord tci = (ColumnInfoRecord)records[k]; if (tci.ContainsColumn(targetColumnIx)) { ci = tci; break; } if (tci.FirstColumn > targetColumnIx) { // call targetColumnIx infos after k are for later targetColumnIxs break; // exit now so k will be the correct insert pos } } if (ci == null) { // okay so there IsN'T a targetColumnIx info record that cover's this targetColumnIx so lets Create one! ColumnInfoRecord nci = new ColumnInfoRecord(); nci.FirstColumn = targetColumnIx; nci.LastColumn = targetColumnIx; SetColumnInfoFields(nci, xfIndex, width, level, hidden, collapsed); InsertColumn(k, nci); AttemptMergeColInfoRecords(k); return; } bool styleChanged = ci.XFIndex != xfIndex; bool widthChanged = ci.ColumnWidth != width; bool levelChanged = ci.OutlineLevel != level; bool hiddenChanged = ci.IsHidden != hidden; bool collapsedChanged = ci.IsCollapsed != collapsed; bool targetColumnIxChanged = styleChanged || widthChanged || levelChanged || hiddenChanged || collapsedChanged; if (!targetColumnIxChanged) { // do nothing...nothing Changed. return; } if ((ci.FirstColumn == targetColumnIx) && (ci.LastColumn == targetColumnIx)) { // if its only for this cell then // ColumnInfo ci for a single column, the target column SetColumnInfoFields(ci, xfIndex, width, level, hidden, collapsed); AttemptMergeColInfoRecords(k); return; } if ((ci.FirstColumn == targetColumnIx) || (ci.LastColumn == targetColumnIx)) { // The target column is at either end of the multi-column ColumnInfo ci // we'll just divide the info and create a new one if (ci.FirstColumn == targetColumnIx) { ci.FirstColumn = targetColumnIx + 1; } else { ci.LastColumn = targetColumnIx - 1; k++; // adjust insert pos to insert after } ColumnInfoRecord nci = CopyColInfo(ci); nci.FirstColumn = targetColumnIx; nci.LastColumn = targetColumnIx; SetColumnInfoFields(nci, xfIndex, width, level, hidden, collapsed); InsertColumn(k, nci); AttemptMergeColInfoRecords(k); } else { //split to 3 records ColumnInfoRecord ciStart = ci; ColumnInfoRecord ciMid = CopyColInfo(ci); ColumnInfoRecord ciEnd = CopyColInfo(ci); int lastcolumn = ci.LastColumn; ciStart.LastColumn = (targetColumnIx - 1); ciMid.FirstColumn=(targetColumnIx); ciMid.LastColumn=(targetColumnIx); SetColumnInfoFields(ciMid, xfIndex, width, level, hidden, collapsed); InsertColumn(++k, ciMid); ciEnd.FirstColumn = (targetColumnIx + 1); ciEnd.LastColumn = (lastcolumn); InsertColumn(++k, ciEnd); // no need to attemptMergeColInfoRecords because we // know both on each side are different } }
/** * merges two column info records (if they are adjacent and have the same formatting, etc) * @return <c>false</c> if the two column records could not be merged */ private static bool MergeColInfoRecords(ColumnInfoRecord ciA, ColumnInfoRecord ciB) { if (ciA.IsAdjacentBefore(ciB) && ciA.FormatMatches(ciB)) { ciA.LastColumn = ciB.LastColumn; return true; } return false; }
public static int CompareColInfos(ColumnInfoRecord a, ColumnInfoRecord b) { return a.FirstColumn - b.FirstColumn; }
/** * Sets all non null fields into the <c>ci</c> parameter. */ private static void SetColumnInfoFields(ColumnInfoRecord ci, short? xfStyle, int? width, int? level, Boolean? hidden, Boolean? collapsed) { if (xfStyle != null) { ci.XFIndex = Convert.ToInt16(xfStyle, CultureInfo.InvariantCulture); } if (width != null) { ci.ColumnWidth = Convert.ToInt32(width, CultureInfo.InvariantCulture); } if (level != null) { ci.OutlineLevel = (short)level; } if (hidden != null) { ci.IsHidden = Convert.ToBoolean(hidden, CultureInfo.InvariantCulture); } if (collapsed != null) { ci.IsCollapsed = Convert.ToBoolean(collapsed, CultureInfo.InvariantCulture); } }
/// <summary> /// Inserts a column into the aggregate (at the position specified /// by index /// </summary> /// <param name="idx">The index.</param> /// <param name="col">The columninfo.</param> public void InsertColumn(int idx, ColumnInfoRecord col) { records.Insert(idx, col); }
/// <summary> /// Inserts a column into the aggregate (at the end of the list). /// </summary> /// <param name="col">The column.</param> public void InsertColumn(ColumnInfoRecord col) { records.Add(col); records.Sort(CIRComparator.instance); }
public bool IsAdjacentBefore(ColumnInfoRecord other) { return(_last_col == other._first_col - 1); }
/** * @return true if the format, options and column width match */ public bool FormatMatches(ColumnInfoRecord other) { if (_xf_index != other._xf_index) { return false; } if (_options != other._options) { return false; } if (_col_width != other._col_width) { return false; } return true; }
public override Object Clone() { ColumnInfoRecord rec = new ColumnInfoRecord(); rec._first_col = _first_col; rec._last_col = _last_col; rec._col_width = _col_width; rec._xf_index = _xf_index; rec._options = _options; rec.field_6_reserved = field_6_reserved; return rec; }
public bool IsAdjacentBefore(ColumnInfoRecord other) { return _last_col == other._first_col - 1; }