From 6d48d8b0baf934acd4344d5c62df4a3d989f57d3 Mon Sep 17 00:00:00 2001 From: Avik Sengupta Date: Wed, 1 Jan 2003 09:24:39 +0000 Subject: [PATCH] PR:15677 git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352975 13f79535-47bb-0310-9956-ffa450edef68 --- .classpath | 4 +-- .project | 2 +- .../apache/poi/hssf/usermodel/HSSFSheet.java | 27 +++++++++++++++++++ .../poi/hssf/usermodel/TestHSSFSheet.java | 21 +++++++++++++++ 4 files changed, 51 insertions(+), 3 deletions(-) diff --git a/.classpath b/.classpath index 434b9d83e1..75589e24b1 100644 --- a/.classpath +++ b/.classpath @@ -3,8 +3,8 @@ - - + + diff --git a/.project b/.project index c9ebc6d364..2a90ecdda8 100644 --- a/.project +++ b/.project @@ -1,6 +1,6 @@ - jakarta-poi + POI diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java index 94e2f31323..17b24aadb1 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java @@ -513,6 +513,33 @@ public class HSSFSheet return record.getVCenter(); } + /** + * determines whether the output is horizontally centered on the page. + * @param value true to horizontally center, false otherwise. + */ + + public void setHorizontallyCenter(boolean value) + { + HCenterRecord record = + (HCenterRecord) sheet.findFirstRecordBySid(HCenterRecord.sid); + + record.setHCenter(value); + } + + /** + * Determine whether printed output for this sheet will be horizontally centered. + */ + + public boolean getHorizontallyCenter() + { + HCenterRecord record = + (HCenterRecord) sheet.findFirstRecordBySid(HCenterRecord.sid); + + return record.getHCenter(); + } + + + /** * removes a merged region of cells (hence letting them free) * @param index of the region to unmerge diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java index 9b57ac8709..27aa0e24fa 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java @@ -56,6 +56,7 @@ package org.apache.poi.hssf.usermodel; import junit.framework.TestCase; import org.apache.poi.hssf.model.Sheet; +import org.apache.poi.hssf.record.HCenterRecord; import org.apache.poi.hssf.record.VCenterRecord; import org.apache.poi.hssf.record.WSBoolRecord; @@ -115,6 +116,26 @@ public class TestHSSFSheet // wb.write(new FileOutputStream("c:\\test.xls")); } + /** + * Test horizontally centered output. + */ + + public void testHorizontallyCenter() + throws Exception + { + HSSFWorkbook wb = new HSSFWorkbook(); + HSSFSheet s = wb.createSheet(); + Sheet sheet = s.getSheet(); + HCenterRecord record = + (HCenterRecord) sheet.findFirstRecordBySid(HCenterRecord.sid); + + assertEquals(false, record.getHCenter()); + s.setHorizontallyCenter(true); + assertEquals(true, record.getHCenter()); + + } + + /** * Test WSBboolRecord fields get set in the user model. */ -- 2.39.5