Fix bug #55050 - If the start+end row and cell are the same on an AreaPtg, avoid inverting the relative flag
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1614928 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
da61e7dd32
commit
2ee05730bd
@ -71,7 +71,7 @@ public abstract class AreaPtgBase extends OperandPtg implements AreaI {
|
||||
protected AreaPtgBase(int firstRow, int lastRow, int firstColumn, int lastColumn,
|
||||
boolean firstRowRelative, boolean lastRowRelative, boolean firstColRelative, boolean lastColRelative) {
|
||||
|
||||
if (lastRow > firstRow) {
|
||||
if (lastRow >= firstRow) {
|
||||
setFirstRow(firstRow);
|
||||
setLastRow(lastRow);
|
||||
setFirstRowRelative(firstRowRelative);
|
||||
@ -83,7 +83,7 @@ public abstract class AreaPtgBase extends OperandPtg implements AreaI {
|
||||
setLastRowRelative(firstRowRelative);
|
||||
}
|
||||
|
||||
if (lastColumn > firstColumn) {
|
||||
if (lastColumn >= firstColumn) {
|
||||
setFirstColumn(firstColumn);
|
||||
setLastColumn(lastColumn);
|
||||
setFirstColRelative(firstColRelative);
|
||||
|
@ -71,6 +71,35 @@ public final class TestAreaPtg extends TestCase {
|
||||
assertEquals(lc , aptg.getLastColumn() );
|
||||
}
|
||||
|
||||
public void testAbsoluteRelativeRefs() {
|
||||
AreaPtg sca1 = new AreaPtg(4, 5, 6, 7, true, false, true, false);
|
||||
AreaPtg sca2 = new AreaPtg(4, 5, 6, 7, false, true, false, true);
|
||||
AreaPtg sca3 = new AreaPtg(5, 5, 7, 7, true, false, true, false);
|
||||
AreaPtg sca4 = new AreaPtg(5, 5, 7, 7, false, true, false, true);
|
||||
|
||||
assertEquals("first rel., last abs.", "G5:$H$6", sca1.toFormulaString());
|
||||
assertEquals("first abs., last rel.", "$G$5:H6", sca2.toFormulaString());
|
||||
assertEquals("first rel., last abs.", "H6:$H$6", sca3.toFormulaString());
|
||||
assertEquals("first abs., last rel.", "$H$6:H6", sca4.toFormulaString());
|
||||
|
||||
AreaPtg cla1 = cloneArea(sca1);
|
||||
AreaPtg cla2 = cloneArea(sca2);
|
||||
AreaPtg cla3 = cloneArea(sca3);
|
||||
AreaPtg cla4 = cloneArea(sca4);
|
||||
|
||||
assertEquals("first rel., last abs.", "G5:$H$6", cla1.toFormulaString());
|
||||
assertEquals("first abs., last rel.", "$G$5:H6", cla2.toFormulaString());
|
||||
assertEquals("first rel., last abs.", "H6:$H$6", cla3.toFormulaString());
|
||||
assertEquals("first abs., last rel.", "$H$6:H6", cla4.toFormulaString());
|
||||
}
|
||||
private AreaPtg cloneArea(AreaPtg a)
|
||||
{
|
||||
return new AreaPtg(
|
||||
a.getFirstRow(), a.getLastRow(), a.getFirstColumn(), a.getLastColumn(),
|
||||
a.isFirstRowRelative(), a.isLastRowRelative(), a.isFirstColRelative(), a.isLastColRelative()
|
||||
);
|
||||
}
|
||||
|
||||
public void testFormulaParser()
|
||||
{
|
||||
String formula1="SUM($E$5:$E$6)";
|
||||
|
Loading…
Reference in New Issue
Block a user