aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYegor Kozlov <yegor@apache.org>2012-02-27 15:22:22 +0000
committerYegor Kozlov <yegor@apache.org>2012-02-27 15:22:22 +0000
commitf3d9f2bdd9469742f8a90eb55dece945830af0bd (patch)
tree127e996b1dadcc913fe0656655db7c1a8c6a98f2 /src
parent3b7638611bdd4e9d9b3dfcbb229c902f28da5710 (diff)
downloadpoi-f3d9f2bdd9469742f8a90eb55dece945830af0bd.tar.gz
poi-f3d9f2bdd9469742f8a90eb55dece945830af0bd.zip
Bugzilla 52574 - support setting header / footer page margins in HSSF
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1294181 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/documentation/content/xdocs/status.xml2
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java20
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java2
-rw-r--r--src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java5
4 files changed, 26 insertions, 3 deletions
diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml
index cbd39ea9de..7bb0f71feb 100644
--- a/src/documentation/content/xdocs/status.xml
+++ b/src/documentation/content/xdocs/status.xml
@@ -34,6 +34,8 @@
<changes>
<release version="3.8-beta6" date="2012-??-??">
+ <action dev="poi-developers" type="add">52574 - support setting header / footer page margins in HSSF </action>
+ <action dev="poi-developers" type="add">52583 - fixed WorkbookUtil#createSafeSheetName to escape colon </action>
<action dev="poi-developers" type="add">51710 - fixed reading shared formulas in XSSF </action>
<action dev="poi-developers" type="add">52708 - misc improvements in CellFormat </action>
<action dev="poi-developers" type="add">52690 - added a getter for length of encrypted data in Ecma and Agile decryptors</action>
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
index a1bc0f36b7..48e87b85a8 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
@@ -1062,7 +1062,14 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
* @return the size of the margin
*/
public double getMargin(short margin) {
- return _sheet.getPageSettings().getMargin(margin);
+ switch (margin){
+ case FooterMargin:
+ return _sheet.getPageSettings().getPrintSetup().getFooterMargin();
+ case HeaderMargin:
+ return _sheet.getPageSettings().getPrintSetup().getHeaderMargin();
+ default:
+ return _sheet.getPageSettings().getMargin(margin);
+ }
}
/**
@@ -1071,7 +1078,16 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
* @param size the size of the margin
*/
public void setMargin(short margin, double size) {
- _sheet.getPageSettings().setMargin(margin, size);
+ switch (margin){
+ case FooterMargin:
+ _sheet.getPageSettings().getPrintSetup().setFooterMargin(size);
+ break;
+ case HeaderMargin:
+ _sheet.getPageSettings().getPrintSetup().setHeaderMargin(size);
+ break;
+ default:
+ _sheet.getPageSettings().setMargin(margin, size);
+ }
}
private WorksheetProtectionBlock getProtectionBlock() {
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
index 2d0566a3d3..0235e4150f 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
@@ -2673,7 +2673,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
CTCellFormula sf = (CTCellFormula)f.copy();
CellRangeAddress sfRef = CellRangeAddress.valueOf(sf.getRef());
CellReference cellRef = new CellReference(cell);
- // If the shared formula range preceeds the master cell then the preseeing part is discarded, e.g.
+ // If the shared formula range preceeds the master cell then the preceding part is discarded, e.g.
// if the cell is E60 and the shared formula range is C60:M85 then the effective range is E60:M85
// see more details in https://issues.apache.org/bugzilla/show_bug.cgi?id=51710
if(cellRef.getCol() > sfRef.getFirstColumn() || cellRef.getRow() > sfRef.getFirstRow()){
diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java
index bd2b8f3771..7a3c213bab 100644
--- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java
+++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java
@@ -557,6 +557,11 @@ public abstract class BaseTestSheet extends TestCase {
sheet.setMargin(Sheet.BottomMargin, 13.0);
assertEquals(13.0, sheet.getMargin(Sheet.BottomMargin), 0.0);
+ sheet.setMargin(Sheet.FooterMargin, 5.6);
+ assertEquals(5.6, sheet.getMargin(Sheet.FooterMargin), 0.0);
+ sheet.setMargin(Sheet.HeaderMargin, 11.5);
+ assertEquals(11.5, sheet.getMargin(Sheet.HeaderMargin), 0.0);
+
// incorrect margin constant
try {
sheet.setMargin((short) 65, 15);