poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ye...@apache.org
Subject svn commit: r562536 - in /poi/trunk/src: java/org/apache/poi/hssf/model/ConvertAnchor.java testcases/org/apache/poi/hssf/usermodel/TestHSSFClientAnchor.java
Date Fri, 03 Aug 2007 18:09:42 GMT
Author: yegor
Date: Fri Aug  3 11:09:41 2007
New Revision: 562536

URL: http://svn.apache.org/viewvc?view=rev&rev=562536
Log:
fixed Bug 42999: HSSFPatriarch positioning problem

Modified:
    poi/trunk/src/java/org/apache/poi/hssf/model/ConvertAnchor.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFClientAnchor.java

Modified: poi/trunk/src/java/org/apache/poi/hssf/model/ConvertAnchor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/model/ConvertAnchor.java?view=diff&rev=562536&r1=562535&r2=562536
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/model/ConvertAnchor.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/model/ConvertAnchor.java Fri Aug  3 11:09:41 2007
@@ -40,14 +40,14 @@
             anchor.setOptions( (short) 0x0000 );
             anchor.setFlag( (short) a.getAnchorType() );
             anchor.setCol1( (short) Math.min(a.getCol1(), a.getCol2()) );
-            anchor.setDx1( (short) Math.min(a.getDx1(), a.getDx2()) );
+            anchor.setDx1( (short) a.getDx1() );
             anchor.setRow1( (short) Math.min(a.getRow1(), a.getRow2()) );
-            anchor.setDy1( (short) Math.min(a.getDy1(), a.getDy2()) );
+            anchor.setDy1( (short) a.getDy1() );
 
             anchor.setCol2( (short) Math.max(a.getCol1(), a.getCol2()) );
-            anchor.setDx2( (short) Math.max(a.getDx1(), a.getDx2()) );
+            anchor.setDx2( (short) a.getDx2() );
             anchor.setRow2( (short) Math.max(a.getRow1(), a.getRow2()) );
-            anchor.setDy2( (short) Math.max(a.getDy1(), a.getDy2() ) );
+            anchor.setDy2( (short) a.getDy2() );
             return anchor;
         }
         else

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFClientAnchor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFClientAnchor.java?view=diff&rev=562536&r1=562535&r2=562536
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFClientAnchor.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFClientAnchor.java Fri Aug
 3 11:09:41 2007
@@ -18,11 +18,14 @@
 package org.apache.poi.hssf.usermodel;
 
 import junit.framework.TestCase;
+import org.apache.poi.ddf.EscherClientAnchorRecord;
+import org.apache.poi.hssf.model.ConvertAnchor;
 
 /**
  * Various tests for HSSFClientAnchor.
  *
  * @author Glen Stampoultzis (glens at apache.org)
+ * @author Yegor Kozlov (yegor at apache.org)
  */
 public class TestHSSFClientAnchor extends TestCase
 {
@@ -58,4 +61,28 @@
 
     }
 
+    /**
+     * When HSSFClientAnchor is converted into EscherClientAnchorRecord
+     * check that dx1, dx2, dy1 and dy2 are writtem "as is".
+     * (Bug 42999 reported that dx1 ans dx2 are swapped if dx1>dx2. It doesn't make sense
for client anchors.)
+     */
+    public void testConvertAnchor() throws Exception
+    {
+        HSSFClientAnchor[] anchor = {
+            new HSSFClientAnchor( 0 , 0 , 0 , 0 ,(short)0, 1,(short)1,3),
+            new HSSFClientAnchor( 100 , 0 , 900 , 255 ,(short)0, 1,(short)1,3),
+            new HSSFClientAnchor( 900 , 0 , 100 , 255 ,(short)0, 1,(short)1,3)
+        };
+        for (int i = 0; i < anchor.length; i++) {
+            EscherClientAnchorRecord record = (EscherClientAnchorRecord)ConvertAnchor.createAnchor(anchor[i]);
+            assertEquals(anchor[i].getDx1(), record.getDx1());
+            assertEquals(anchor[i].getDx2(), record.getDx2());
+            assertEquals(anchor[i].getDy1(), record.getDy1());
+            assertEquals(anchor[i].getDy2(), record.getDy2());
+            assertEquals(anchor[i].getCol1(), record.getCol1());
+            assertEquals(anchor[i].getCol2(), record.getCol2());
+            assertEquals(anchor[i].getRow1(), record.getRow1());
+            assertEquals(anchor[i].getRow2(), record.getRow2());
+        }
+    }
 }



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


Mime
View raw message