fixed Bug 42999: HSSFPatriarch positioning problem
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@562536 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
222e406a69
commit
0171d85885
@ -40,14 +40,14 @@ public class ConvertAnchor
|
|||||||
anchor.setOptions( (short) 0x0000 );
|
anchor.setOptions( (short) 0x0000 );
|
||||||
anchor.setFlag( (short) a.getAnchorType() );
|
anchor.setFlag( (short) a.getAnchorType() );
|
||||||
anchor.setCol1( (short) Math.min(a.getCol1(), a.getCol2()) );
|
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.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.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.setRow2( (short) Math.max(a.getRow1(), a.getRow2()) );
|
||||||
anchor.setDy2( (short) Math.max(a.getDy1(), a.getDy2() ) );
|
anchor.setDy2( (short) a.getDy2() );
|
||||||
return anchor;
|
return anchor;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -18,11 +18,14 @@
|
|||||||
package org.apache.poi.hssf.usermodel;
|
package org.apache.poi.hssf.usermodel;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
import org.apache.poi.ddf.EscherClientAnchorRecord;
|
||||||
|
import org.apache.poi.hssf.model.ConvertAnchor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Various tests for HSSFClientAnchor.
|
* Various tests for HSSFClientAnchor.
|
||||||
*
|
*
|
||||||
* @author Glen Stampoultzis (glens at apache.org)
|
* @author Glen Stampoultzis (glens at apache.org)
|
||||||
|
* @author Yegor Kozlov (yegor at apache.org)
|
||||||
*/
|
*/
|
||||||
public class TestHSSFClientAnchor extends TestCase
|
public class TestHSSFClientAnchor extends TestCase
|
||||||
{
|
{
|
||||||
@ -58,4 +61,28 @@ public class TestHSSFClientAnchor extends TestCase
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user