protected override void DoArea(TAreaToken areat, bool RefIsInInsertingSheet) { int r1 = areat.Row1; int r2 = areat.Row2; int c1 = areat.Col1; int c2 = areat.Col2; if (RefIsInInsertingSheet) { TXlsCellRange NewRange = CellRange.Offset(NewRow, NewCol); bool RowRel1 = areat.CanHaveRelativeOffsets && !areat.RowAbs1; //CanHaveRelativeOffsets is true for RefN tokens. bool ColRel1 = areat.CanHaveRelativeOffsets && !areat.ColAbs1; bool RowRel2 = areat.CanHaveRelativeOffsets && !areat.RowAbs2; bool ColRel2 = areat.CanHaveRelativeOffsets && !areat.ColAbs2; if (RowRel1) { r1 = TBaseRefToken.WrapRow(FmlaRow + r1, false); } if (ColRel1) { c1 = TBaseRefToken.WrapColumn(FmlaCol + c1, false); } if (RowRel2) { r2 = TBaseRefToken.WrapRow(FmlaRow + r2, false); } if (ColRel2) { c2 = TBaseRefToken.WrapColumn(FmlaCol + c2, false); } bool RefInside = CellRange.HasRow(r1) && CellRange.HasCol(c1) && CellRange.HasRow(r2) && CellRange.HasCol(c2); bool FmlaInside = CellRange.HasRow(FmlaRow) && CellRange.HasCol(FmlaCol); //only if the ref was *not* on the original range. if (!RefInside && NewRange.HasRow(r1) && NewRange.HasCol(c1) && NewRange.HasRow(r2) && NewRange.HasCol(c2)) { areat.CreateInvalidRef(); } else { r1 = MoveRef(areat, ref areat.Row1, r1, 0, NewRow - CellRange.Top, FmlaRow, RowRel1, RefInside, FmlaInside, FlxConsts.Max_Rows, false); c1 = MoveRef(areat, ref areat.Col1, c1, 0, NewCol - CellRange.Left, FmlaCol, ColRel1, RefInside, FmlaInside, FlxConsts.Max_Columns, false); r2 = MoveRef(areat, ref areat.Row2, r2, 0, NewRow - CellRange.Top, FmlaRow, RowRel2, RefInside, FmlaInside, FlxConsts.Max_Rows, false); c2 = MoveRef(areat, ref areat.Col2, c2, 0, NewCol - CellRange.Left, FmlaCol, ColRel2, RefInside, FmlaInside, FlxConsts.Max_Columns, false); } } if (Bounds != null) { Bounds.AddRow(r1); Bounds.AddRow(r2); Bounds.AddCol(c1); Bounds.AddCol(c2); } }
protected override void DoRef(TRefToken reft, bool RefIsInInsertingSheet) { int r = reft.Row; int c = reft.Col; if (RefIsInInsertingSheet) { TXlsCellRange NewRange = CellRange.Offset(NewRow, NewCol); bool RowIsOffset = reft.CanHaveRelativeOffsets && !reft.RowAbs; //CanHaveRelativeOffsets is true for RefN tokens. bool ColIsOffset = reft.CanHaveRelativeOffsets && !reft.ColAbs; if (RowIsOffset) { r = TBaseRefToken.WrapRow(FmlaRow + r, false); } if (ColIsOffset) { c = TBaseRefToken.WrapColumn(FmlaCol + c, false); } bool RefInside = CellRange.HasRow(r) && CellRange.HasCol(c); bool FmlaInside = CellRange.HasRow(FmlaRow) && CellRange.HasCol(FmlaCol); //only if the ref was *not* on the original range. if (!RefInside && NewRange.HasRow(r) && NewRange.HasCol(c)) { reft.CreateInvalidRef(); } else { r = MoveRef(reft, ref reft.Row, r, 0, NewRow - CellRange.Top, FmlaRow, RowIsOffset, RefInside, FmlaInside, FlxConsts.Max_Rows, false); c = MoveRef(reft, ref reft.Col, c, 0, NewCol - CellRange.Left, FmlaCol, ColIsOffset, RefInside, FmlaInside, FlxConsts.Max_Columns, false); } } if (Bounds != null) { Bounds.AddRow(r); Bounds.AddCol(c); } }
internal bool Find(int Row, int Col, out int Index) { //There should never be too much ranges here, so a linear search should be enough for (int i = Ranges.Count - 1; i >= 0; i--) { TXlsCellRange c = Ranges[i]; if (c.HasRow(Row) && c.HasCol(Col)) { Index = i; return(true); } } Index = -1; return(false); }
protected override void DoRef(TRefToken reft, bool RefIsInInsertingSheet) { int r = reft.Row; int c = reft.Col; if (RefIsInInsertingSheet) { bool RowIsOffset = reft.CanHaveRelativeOffsets && !reft.RowAbs; //CanHaveRelativeOffsets is true for RefN tokens. bool ColIsOffset = reft.CanHaveRelativeOffsets && !reft.ColAbs; if (RowIsOffset) { r = TBaseRefToken.WrapRow(FmlaRow + r, false); } if (ColIsOffset) { c = TBaseRefToken.WrapColumn(FmlaCol + c, false); } bool FmlaInsideDown = (FmlaRow >= CellRange.Top) && CellRange.HasCol(FmlaCol); bool FmlaInsideRight = (FmlaCol >= CellRange.Left) && CellRange.HasRow(FmlaRow); bool RefInsideDown = (r >= CellRange.Top) && (CellRange.HasCol(c)); bool RefInsideRight = (c >= CellRange.Left) && (CellRange.HasRow(r)); r = MoveRef(reft, ref reft.Row, r, CellRange.Top, RowCount * CellRange.RowCount, FmlaRow, RowIsOffset, RefInsideDown, FmlaInsideDown, FlxConsts.Max_Rows, true); c = MoveRef(reft, ref reft.Col, c, CellRange.Left, ColCount * CellRange.ColCount, FmlaCol, ColIsOffset, RefInsideRight, FmlaInsideRight, FlxConsts.Max_Columns, true); } bool ForgetAbsolute = SemiAbsoluteMode && CellRange.HasRow(r) && CellRange.HasCol(c); OffsetCopy(reft, ref reft.Row, CopyRowOffset, FlxConsts.Max_Rows, reft.RowAbs, ForgetAbsolute); OffsetCopy(reft, ref reft.Col, CopyColOffset, FlxConsts.Max_Columns, reft.ColAbs, ForgetAbsolute); if (Bounds != null) { Bounds.AddRow(reft.Row); Bounds.AddCol(reft.Col); } }
private void ArrangeTokenTableAndArray(ref int Row, ref int Col) { if (Bounds != null) { Bounds.Sheet1 = -2; } if (SheetInfo.SourceFormulaSheet != SheetInfo.InsSheet) { return; } TXlsCellRange NewRange = CellRange.Offset(NewRow, NewCol); if (CellRange.HasRow(Row) && CellRange.HasCol(Col)) { IncRowColForTableArray(ref Row, -1, NewRow - CellRange.Top, FlxConsts.Max_Rows, false); IncRowColForTableArray(ref Col, -1, NewCol - CellRange.Left, FlxConsts.Max_Columns, false); } else if (NewRange.HasRow(Row) && NewRange.HasCol(Col)) { FlxMessages.ThrowException(FlxErr.ErrInternal); //we should never have an error when updating tables or exp tokens. The error should show when deleting the cell } }