Exemplo n.º 1
0
        private Ptg RowMoveRefPtg(RefPtgBase rptg)
        {
            int refRow = rptg.Row;

            if (_firstMovedIndex <= refRow && refRow <= _lastMovedIndex)
            {
                // Rows being moved completely enclose the ref.
                // - move the area ref along with the rows regardless of destination
                rptg.Row = (refRow + _amountToMove);
                return(rptg);
            }
            // else rules for adjusting area may also depend on the destination of the moved rows

            int destFirstRowIndex = _firstMovedIndex + _amountToMove;
            int destLastRowIndex  = _lastMovedIndex + _amountToMove;

            // ref is outside source rows
            // check for clashes with destination

            if (destLastRowIndex < refRow || refRow < destFirstRowIndex)
            {
                // destination rows are completely outside ref
                return(null);
            }

            if (destFirstRowIndex <= refRow && refRow <= destLastRowIndex)
            {
                // destination rows enclose the area (possibly exactly)
                return(CreateDeletedRef(rptg));
            }
            throw new InvalidOperationException("Situation not covered: (" + _firstMovedIndex + ", " +
                                                _lastMovedIndex + ", " + _amountToMove + ", " + refRow + ", " + refRow + ")");
        }
Exemplo n.º 2
0
        private Ptg RowMoveRefPtg(RefPtgBase rptg)
        {
            int refRow = rptg.Row;
            if (_firstMovedIndex <= refRow && refRow <= _lastMovedIndex)
            {
                // Rows being moved completely enclose the ref.
                // - move the area ref along with the rows regardless of destination
                rptg.Row = (refRow + _amountToMove);
                return rptg;
            }
            // else rules for adjusting area may also depend on the destination of the moved rows

            int destFirstRowIndex = _firstMovedIndex + _amountToMove;
            int destLastRowIndex = _lastMovedIndex + _amountToMove;

            // ref is outside source rows
            // check for clashes with destination

            if (destLastRowIndex < refRow || refRow < destFirstRowIndex)
            {
                // destination rows are completely outside ref
                return null;
            }

            if (destFirstRowIndex <= refRow && refRow <= destLastRowIndex)
            {
                // destination rows enclose the area (possibly exactly)
                return CreateDeletedRef(rptg);
            }
            throw new InvalidOperationException("Situation not covered: (" + _firstMovedIndex + ", " +
                        _lastMovedIndex + ", " + _amountToMove + ", " + refRow + ", " + refRow + ")");
        }