poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1614928 - in /poi/trunk/src: java/org/apache/poi/ss/formula/ptg/AreaPtgBase.java testcases/org/apache/poi/ss/formula/ptg/TestAreaPtg.java
Date Thu, 31 Jul 2014 16:06:44 GMT
Author: nick
Date: Thu Jul 31 16:06:43 2014
New Revision: 1614928

URL: http://svn.apache.org/r1614928
Log:
Fix bug #55050 - If the start+end row and cell are the same on an AreaPtg, avoid inverting
the relative flag

Modified:
    poi/trunk/src/java/org/apache/poi/ss/formula/ptg/AreaPtgBase.java
    poi/trunk/src/testcases/org/apache/poi/ss/formula/ptg/TestAreaPtg.java

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/ptg/AreaPtgBase.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/ptg/AreaPtgBase.java?rev=1614928&r1=1614927&r2=1614928&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/ptg/AreaPtgBase.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/ptg/AreaPtgBase.java Thu Jul 31 16:06:43
2014
@@ -71,7 +71,7 @@ public abstract class AreaPtgBase extend
 	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 extend
 			setLastRowRelative(firstRowRelative);
 		}
 
-		if (lastColumn > firstColumn) {
+		if (lastColumn >= firstColumn) {
 			setFirstColumn(firstColumn);
 			setLastColumn(lastColumn);
 			setFirstColRelative(firstColRelative);

Modified: poi/trunk/src/testcases/org/apache/poi/ss/formula/ptg/TestAreaPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/formula/ptg/TestAreaPtg.java?rev=1614928&r1=1614927&r2=1614928&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/formula/ptg/TestAreaPtg.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/formula/ptg/TestAreaPtg.java Thu Jul 31 16:06:43
2014
@@ -71,6 +71,35 @@ public final class TestAreaPtg extends T
 		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)";



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message