Search in sources :

Example 11 with AreaPtg

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);
}
Also used : AreaPtg(org.apache.poi.ss.formula.ptg.AreaPtg) Test(org.junit.Test)

Example 12 with AreaPtg

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);
}
Also used : AreaPtg(org.apache.poi.ss.formula.ptg.AreaPtg) Test(org.junit.Test)

Example 13 with AreaPtg

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);
}
Also used : AreaPtg(org.apache.poi.ss.formula.ptg.AreaPtg) Test(org.junit.Test)

Example 14 with AreaPtg

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);
}
Also used : AreaPtg(org.apache.poi.ss.formula.ptg.AreaPtg)

Example 15 with AreaPtg

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);
}
Also used : AreaPtg(org.apache.poi.ss.formula.ptg.AreaPtg) AssertionFailedError(junit.framework.AssertionFailedError)

Aggregations

AreaPtg (org.apache.poi.ss.formula.ptg.AreaPtg)15 Test (org.junit.Test)7 Ptg (org.apache.poi.ss.formula.ptg.Ptg)5 AreaErrPtg (org.apache.poi.ss.formula.ptg.AreaErrPtg)4 Ref3DPtg (org.apache.poi.ss.formula.ptg.Ref3DPtg)3 CellRangeAddress (org.apache.poi.ss.util.CellRangeAddress)3 RefPtg (org.apache.poi.ss.formula.ptg.RefPtg)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 AssertionFailedError (junit.framework.AssertionFailedError)1 FormulaRecordAggregate (org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate)1 Area3DPtg (org.apache.poi.ss.formula.ptg.Area3DPtg)1 FuncPtg (org.apache.poi.ss.formula.ptg.FuncPtg)1 FuncVarPtg (org.apache.poi.ss.formula.ptg.FuncVarPtg)1 LittleEndianInput (org.apache.poi.util.LittleEndianInput)1 LittleEndianInputStream (org.apache.poi.util.LittleEndianInputStream)1