fix reopen of bug 42999: incorrect AnchorHeight calculations in HSSFClientAnchor.getAnchorHeightInPoints

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@606684 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yegor Kozlov 2007-12-24 09:48:11 +00:00
parent d47c14c347
commit d38fd2ac9a
2 changed files with 21 additions and 2 deletions

View File

@ -82,8 +82,8 @@ public class HSSFClientAnchor
*/
public float getAnchorHeightInPoints(HSSFSheet sheet )
{
int y1 = Math.min( getDy1(), getDy2() );
int y2 = Math.max( getDy1(), getDy2() );
int y1 = getDy1();
int y2 = getDy2();
int row1 = Math.min( getRow1(), getRow2() );
int row2 = Math.max( getRow1(), getRow2() );

View File

@ -85,4 +85,23 @@ public class TestHSSFClientAnchor extends TestCase
assertEquals(anchor[i].getRow2(), record.getRow2());
}
}
public void testAnchorHeightInPoints(){
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet();
HSSFClientAnchor[] anchor = {
new HSSFClientAnchor( 0 , 0, 0 , 0 ,(short)0, 1,(short)1, 3),
new HSSFClientAnchor( 0 , 254 , 0 , 126 ,(short)0, 1,(short)1, 3),
new HSSFClientAnchor( 0 , 128 , 0 , 128 ,(short)0, 1,(short)1, 3),
new HSSFClientAnchor( 0 , 0 , 0 , 128 ,(short)0, 1,(short)1, 3),
};
float[] ref = {24.0f, 18.0f, 24.0f, 30.0f};
for (int i = 0; i < anchor.length; i++) {
float height = anchor[i].getAnchorHeightInPoints(sheet);
assertEquals(ref[i], height, 0);
}
}
}