aboutsummaryrefslogtreecommitdiffstats
path: root/src/ooxml/java
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2008-08-05 10:22:13 +0000
committerNick Burch <nick@apache.org>2008-08-05 10:22:13 +0000
commite7476735dc742bd5c6e86419572f6c96f98ecae2 (patch)
tree73b8c7fa0fa06bcde9f8852cc7dd1deeb50a3c1f /src/ooxml/java
parent9a34ef8fd38cfbecb7615099d9482981c6df8e4a (diff)
downloadpoi-e7476735dc742bd5c6e86419572f6c96f98ecae2.tar.gz
poi-e7476735dc742bd5c6e86419572f6c96f98ecae2.zip
Improve support, tests and documentation for xssf headers and footers
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@682662 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/java')
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvenFooter.java6
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvenHeader.java6
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFirstFooter.java7
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFirstHeader.java6
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFOddFooter.java7
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFOddHeader.java7
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java70
7 files changed, 86 insertions, 23 deletions
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvenFooter.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvenFooter.java
index a215285a21..759b3e4d26 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvenFooter.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvenFooter.java
@@ -32,7 +32,11 @@ public class XSSFEvenFooter extends XSSFHeaderFooter implements Footer{
}
public void setText(String text) {
- getHeaderFooter().setEvenFooter(text);
+ if(text == null) {
+ getHeaderFooter().unsetEvenFooter();
+ } else {
+ getHeaderFooter().setEvenFooter(text);
+ }
}
}
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvenHeader.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvenHeader.java
index 670b498012..0a63110ba0 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvenHeader.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvenHeader.java
@@ -32,7 +32,11 @@ public class XSSFEvenHeader extends XSSFHeaderFooter implements Header{
}
public void setText(String text) {
- getHeaderFooter().setEvenHeader(text);
+ if(text == null) {
+ getHeaderFooter().unsetEvenHeader();
+ } else {
+ getHeaderFooter().setEvenHeader(text);
+ }
}
}
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFirstFooter.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFirstFooter.java
index e9a1f37764..7d2df77d75 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFirstFooter.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFirstFooter.java
@@ -32,7 +32,10 @@ public class XSSFFirstFooter extends XSSFHeaderFooter implements Footer{
}
public void setText(String text) {
- getHeaderFooter().setFirstFooter(text);
+ if(text == null) {
+ getHeaderFooter().unsetFirstFooter();
+ } else {
+ getHeaderFooter().setFirstFooter(text);
+ }
}
-
}
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFirstHeader.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFirstHeader.java
index 17e5a70861..27a7520d42 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFirstHeader.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFirstHeader.java
@@ -32,7 +32,11 @@ public class XSSFFirstHeader extends XSSFHeaderFooter implements Header{
}
public void setText(String text) {
- getHeaderFooter().setFirstHeader(text);
+ if(text == null) {
+ getHeaderFooter().unsetFirstHeader();
+ } else {
+ getHeaderFooter().setFirstHeader(text);
+ }
}
}
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFOddFooter.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFOddFooter.java
index 709212ef8d..8e3143b0d1 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFOddFooter.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFOddFooter.java
@@ -32,7 +32,10 @@ public class XSSFOddFooter extends XSSFHeaderFooter implements Footer{
}
public void setText(String text) {
- getHeaderFooter().setOddFooter(text);
+ if(text == null) {
+ getHeaderFooter().unsetOddFooter();
+ } else {
+ getHeaderFooter().setOddFooter(text);
+ }
}
-
}
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFOddHeader.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFOddHeader.java
index e03a6491f0..5ee37cc00a 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFOddHeader.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFOddHeader.java
@@ -32,7 +32,10 @@ public class XSSFOddHeader extends XSSFHeaderFooter implements Header{
}
public void setText(String text) {
- getHeaderFooter().setOddHeader(text);
+ if(text == null) {
+ getHeaderFooter().unsetOddHeader();
+ } else {
+ getHeaderFooter().setOddHeader(text);
+ }
}
-
}
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 18c0e8f161..a76711a7f3 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
@@ -381,14 +381,7 @@ public class XSSFSheet implements Sheet {
return getSheetTypePageSetUpPr().getFitToPage();
}
- public Footer getFooter() {
- return getOddFooter();
- }
- public Footer getOddFooter() {
- return new XSSFOddFooter(getSheetTypeHeaderFooter());
- }
-
protected CTHeaderFooter getSheetTypeHeaderFooter() {
if (worksheet.getHeaderFooter() == null) {
worksheet.setHeaderFooter(CTHeaderFooter.Factory.newInstance());
@@ -396,31 +389,80 @@ public class XSSFSheet implements Sheet {
return worksheet.getHeaderFooter();
}
+ /**
+ * Returns the default footer for the sheet,
+ * creating one as needed.
+ * You may also want to look at
+ * {@link #getFirstFooter()},
+ * {@link #getOddFooter()} and
+ * {@link #getEvenFooter()}
+ */
+ public Footer getFooter() {
+ // The default footer is an odd footer
+ return getOddFooter();
+ }
+
+ /**
+ * Returns the default header for the sheet,
+ * creating one as needed.
+ * You may also want to look at
+ * {@link #getFirstHeader()},
+ * {@link #getOddHeader()} and
+ * {@link #getEvenHeader()}
+ */
+ public Header getHeader() {
+ // The default header is an odd header
+ return getOddHeader();
+ }
+
+ /**
+ * Returns the odd footer. Used on all pages unless
+ * other footers also present, when used on only
+ * odd pages.
+ */
+ public Footer getOddFooter() {
+ return new XSSFOddFooter(getSheetTypeHeaderFooter());
+ }
+ /**
+ * Returns the even footer. Not there by default, but
+ * when set, used on even pages.
+ */
public Footer getEvenFooter() {
return new XSSFEvenFooter(getSheetTypeHeaderFooter());
}
-
+ /**
+ * Returns the first page footer. Not there by
+ * default, but when set, used on the first page.
+ */
public Footer getFirstFooter() {
return new XSSFFirstFooter(getSheetTypeHeaderFooter());
}
- public Header getHeader() {
- return getOddHeader();
- }
-
+ /**
+ * Returns the odd header. Used on all pages unless
+ * other headers also present, when used on only
+ * odd pages.
+ */
public Header getOddHeader() {
return new XSSFOddHeader(getSheetTypeHeaderFooter());
}
-
+ /**
+ * Returns the even header. Not there by default, but
+ * when set, used on even pages.
+ */
public Header getEvenHeader() {
return new XSSFEvenHeader(getSheetTypeHeaderFooter()
);
}
-
+ /**
+ * Returns the first page header. Not there by
+ * default, but when set, used on the first page.
+ */
public Header getFirstHeader() {
return new XSSFFirstHeader(getSheetTypeHeaderFooter());
}
+
public boolean getHorizontallyCenter() {
return getSheetTypePrintOptions().getHorizontalCentered();
}