use of org.apache.poi.ss.formula.ptg.AreaPtg in project poi by apache.
the class TestFormulaShifter method testShiftAreasDestRows.
/**
* Tests what happens to an area ref when some outside rows are moved to overlap
* that area ref
*/
@Test
public void testShiftAreasDestRows() {
// all these operations are on an area ref spanning rows 20 to 25
AreaPtg aptg = createAreaPtg(20, 25);
// no change because no overlap:
confirmAreaShift(aptg, 5, 10, 9, 20, 25);
confirmAreaShift(aptg, 5, 10, 21, 20, 25);
confirmAreaShift(aptg, 11, 14, 10, 20, 25);
// converted to DeletedAreaRef
confirmAreaShift(aptg, 7, 17, 10, -1, -1);
// truncation at top
confirmAreaShift(aptg, 5, 15, 7, 23, 25);
// truncation at bottom
confirmAreaShift(aptg, 13, 16, 10, 20, 22);
}
use of org.apache.poi.ss.formula.ptg.AreaPtg in project poi by apache.
the class TestFormulaShifter method testCopyAreasSourceRowsAbsRel.
@Test
public void testCopyAreasSourceRowsAbsRel() {
// aptg is part of a formula in a cell that was just copied to another row
// aptg row references should be updated by the difference in rows that the cell was copied
// No other references besides the cells that were involved in the copy need to be updated
// this makes the row copy significantly different from the row shift, where all references
// in the workbook need to track the row shift
// all these operations are on an area ref spanning rows 10 to 20
final AreaPtg aptg = createAreaPtg(10, 20, false, true);
// Only last row should move
confirmAreaCopy(aptg, 0, 30, 20, 10, 40, true);
//sortTopLeftToBottomRight swapped firstRow and lastRow because firstRow is absolute
confirmAreaCopy(aptg, 15, 25, -15, 5, 10, true);
}
use of org.apache.poi.ss.formula.ptg.AreaPtg in project poi by apache.
the class TestFormulaShifter method testCopyAreasSourceRowsRelRel.
@Test
public void testCopyAreasSourceRowsRelRel() {
// all these operations are on an area ref spanning rows 10 to 20
final AreaPtg aptg = createAreaPtg(10, 20, true, true);
confirmAreaCopy(aptg, 0, 30, 20, 30, 40, true);
//DeletedRef
confirmAreaCopy(aptg, 15, 25, -15, -1, -1, true);
}
use of org.apache.poi.ss.formula.ptg.AreaPtg in project poi by apache.
the class TestUnaryPlusEval method testColumnOperand.
/**
* Test for bug observable at svn revision 618865 (5-Feb-2008)<br/>
* The code for handling column operands had been copy-pasted from the row handling code.
*/
public void testColumnOperand() {
short firstRow = (short) 8;
short lastRow = (short) 12;
short colNum = (short) 5;
AreaPtg areaPtg = new AreaPtg(firstRow, lastRow, colNum, colNum, false, false, false, false);
ValueEval[] values = { new NumberEval(27), new NumberEval(29), // value in row 10
new NumberEval(35), new NumberEval(37), new NumberEval(38) };
ValueEval[] args = { EvalFactory.createAreaEval(areaPtg, values) };
double result = NumericFunctionInvoker.invoke(EvalInstances.UnaryPlus, args, 10, (short) 20);
assertEquals(35, result, 0);
}
use of org.apache.poi.ss.formula.ptg.AreaPtg in project poi by apache.
the class TestAreaEval method testGetValue_bug44950.
public void testGetValue_bug44950() {
// TODO - this test probably isn't testing much anymore
AreaPtg ptg = new AreaPtg("B2:D3");
NumberEval one = new NumberEval(1);
ValueEval[] values = { one, new NumberEval(2), new NumberEval(3), new NumberEval(4), new NumberEval(5), new NumberEval(6) };
AreaEval ae = EvalFactory.createAreaEval(ptg, values);
if (one == ae.getAbsoluteValue(1, 2)) {
throw new AssertionFailedError("Identified bug 44950 a");
}
confirm(1, ae, 1, 1);
confirm(2, ae, 1, 2);
confirm(3, ae, 1, 3);
confirm(4, ae, 2, 1);
confirm(5, ae, 2, 2);
confirm(6, ae, 2, 3);
}
Aggregations