aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorShawn Laubach <slaubach@apache.org>2005-04-22 14:56:35 +0000
committerShawn Laubach <slaubach@apache.org>2005-04-22 14:56:35 +0000
commit7b50bc556698024e347455120d1d1f641b742373 (patch)
tree87f31dc3ca23938edec1bdf6a4f2205952e33a2c /src
parentec5e6acbf3e97b3e2e7ae47cc4b3d0b4b96e6ed8 (diff)
downloadpoi-7b50bc556698024e347455120d1d1f641b742373.tar.gz
poi-7b50bc556698024e347455120d1d1f641b742373.zip
Added underline capability to the header and footer.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353648 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFFooter.java394
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFHeader.java40
2 files changed, 257 insertions, 177 deletions
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFFooter.java b/src/java/org/apache/poi/hssf/usermodel/HSSFFooter.java
index 464513b9cf..40a668fec2 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFFooter.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFFooter.java
@@ -33,184 +33,224 @@ import org.apache.poi.hssf.record.FooterRecord;
*/
public class HSSFFooter extends Object {
- FooterRecord footerRecord;
- String left;
- String center;
- String right;
-
- /**
- * Constructor. Creates a new footer interface from a footer record
- * @param footerRecord Footer record to create the footer with
- */
- protected HSSFFooter(FooterRecord footerRecord) {
- this.footerRecord = footerRecord;
- String foot = footerRecord.getFooter();
- while (foot != null && foot.length() > 1) {
- int pos = foot.length();
- switch (foot.substring(1, 2).charAt(0)) {
- case 'L' :
- if (foot.indexOf("&C") >= 0) {
- pos = Math.min(pos, foot.indexOf("&C"));
- }
- if (foot.indexOf("&R") >= 0) {
- pos = Math.min(pos, foot.indexOf("&R"));
- }
- left = foot.substring(2, pos);
- foot = foot.substring(pos);
- break;
- case 'C' :
- if (foot.indexOf("&L") >= 0) {
- pos = Math.min(pos, foot.indexOf("&L"));
- }
- if (foot.indexOf("&R") >= 0) {
- pos = Math.min(pos, foot.indexOf("&R"));
- }
- center = foot.substring(2, pos);
- foot = foot.substring(pos);
- break;
- case 'R' :
- if (foot.indexOf("&C") >= 0) {
- pos = Math.min(pos, foot.indexOf("&C"));
- }
- if (foot.indexOf("&L") >= 0) {
- pos = Math.min(pos, foot.indexOf("&L"));
- }
- right = foot.substring(2, pos);
- foot = foot.substring(pos);
- break;
- default : foot = null;
+ FooterRecord footerRecord;
+ String left;
+ String center;
+ String right;
+
+ /**
+ * Constructor. Creates a new footer interface from a footer record
+ * @param footerRecord Footer record to create the footer with
+ */
+ protected HSSFFooter(FooterRecord footerRecord) {
+ this.footerRecord = footerRecord;
+ String foot = footerRecord.getFooter();
+ while (foot != null && foot.length() > 1) {
+ int pos = foot.length();
+ switch (foot.substring(1, 2).charAt(0)) {
+ case 'L' :
+ if (foot.indexOf("&C") >= 0) {
+ pos = Math.min(pos, foot.indexOf("&C"));
+ }
+ if (foot.indexOf("&R") >= 0) {
+ pos = Math.min(pos, foot.indexOf("&R"));
+ }
+ left = foot.substring(2, pos);
+ foot = foot.substring(pos);
+ break;
+ case 'C' :
+ if (foot.indexOf("&L") >= 0) {
+ pos = Math.min(pos, foot.indexOf("&L"));
+ }
+ if (foot.indexOf("&R") >= 0) {
+ pos = Math.min(pos, foot.indexOf("&R"));
+ }
+ center = foot.substring(2, pos);
+ foot = foot.substring(pos);
+ break;
+ case 'R' :
+ if (foot.indexOf("&C") >= 0) {
+ pos = Math.min(pos, foot.indexOf("&C"));
+ }
+ if (foot.indexOf("&L") >= 0) {
+ pos = Math.min(pos, foot.indexOf("&L"));
+ }
+ right = foot.substring(2, pos);
+ foot = foot.substring(pos);
+ break;
+ default : foot = null;
+ }
}
}
- }
-
- /**
- * Get the left side of the footer.
- * @return The string representing the left side.
- */
- public String getLeft() {
- return left;
- }
-
- /**
- * Sets the left string.
- * @param newLeft The string to set as the left side.
- */
- public void setLeft(String newLeft) {
- left = newLeft;
- createFooterString();
- }
-
- /**
- * Get the center of the footer.
- * @return The string representing the center.
- */
- public String getCenter() {
- return center;
- }
-
- /**
- * Sets the center string.
- * @param newCenter The string to set as the center.
- */
- public void setCenter(String newCenter) {
- center = newCenter;
- createFooterString();
- }
-
- /**
- * Get the right side of the footer.
- * @return The string representing the right side.
- */
- public String getRight() {
- return right;
- }
-
- /**
- * Sets the right string.
- * @param newRight The string to set as the right side.
- */
- public void setRight(String newRight) {
- right = newRight;
- createFooterString();
- }
-
- /**
- * Creates the complete footer string based on the left, center, and middle
- * strings.
- */
- private void createFooterString() {
- footerRecord.setFooter(
- "&C" + (center == null ? "" : center) +
- "&L" + (left == null ? "" : left) +
- "&R" + (right == null ? "" : right));
- footerRecord.setFooterLength((byte)footerRecord.getFooter().length());
- }
-
- /**
- * Returns the string that represents the change in font size.
- * @param size the new font size
- * @return The special string to represent a new font size
- */
- public static String fontSize(short size) {
- return "&" + size;
- }
-
- /**
- * Returns the string that represents the change in font.
- * @param font the new font
- * @param style the fonts style
- * @return The special string to represent a new font size
- */
- public static String font(String font, String style) {
- return "&\"" + font + "," + style + "\"";
- }
-
- /**
- * Returns the string representing the current page number
- * @return The special string for page number
- */
- public static String page() {
- return "&P";
- }
-
- /**
- * Returns the string representing the number of pages.
- * @return The special string for the number of pages
- */
- public static String numPages() {
- return "&N";
- }
-
- /**
- * Returns the string representing the current date
- * @return The special string for the date
- */
- public static String date() {
- return "&D";
- }
-
- /**
- * Returns the string representing the current time
- * @return The special string for the time
- */
- public static String time() {
- return "&T";
- }
-
- /**
- * Returns the string representing the current file name
- * @return The special string for the file name
- */
- public static String file() {
- return "&F";
- }
-
- /**
- * Returns the string representing the current tab (sheet) name
- * @return The special string for tab name
- */
- public static String tab() {
- return "&A";
- }
+
+ /**
+ * Get the left side of the footer.
+ * @return The string representing the left side.
+ */
+ public String getLeft() {
+ return left;
+ }
+
+ /**
+ * Sets the left string.
+ * @param newLeft The string to set as the left side.
+ */
+ public void setLeft(String newLeft) {
+ left = newLeft;
+ createFooterString();
+ }
+
+ /**
+ * Get the center of the footer.
+ * @return The string representing the center.
+ */
+ public String getCenter() {
+ return center;
+ }
+
+ /**
+ * Sets the center string.
+ * @param newCenter The string to set as the center.
+ */
+ public void setCenter(String newCenter) {
+ center = newCenter;
+ createFooterString();
+ }
+
+ /**
+ * Get the right side of the footer.
+ * @return The string representing the right side.
+ */
+ public String getRight() {
+ return right;
+ }
+
+ /**
+ * Sets the right string.
+ * @param newRight The string to set as the right side.
+ */
+ public void setRight(String newRight) {
+ right = newRight;
+ createFooterString();
+ }
+
+ /**
+ * Creates the complete footer string based on the left, center, and middle
+ * strings.
+ */
+ private void createFooterString() {
+ footerRecord.setFooter(
+ "&C" + (center == null ? "" : center) +
+ "&L" + (left == null ? "" : left) +
+ "&R" + (right == null ? "" : right));
+ footerRecord.setFooterLength((byte)footerRecord.getFooter().length());
+ }
+
+ /**
+ * Returns the string that represents the change in font size.
+ * @param size the new font size
+ * @return The special string to represent a new font size
+ */
+ public static String fontSize(short size) {
+ return "&" + size;
+ }
+
+ /**
+ * Returns the string that represents the change in font.
+ * @param font the new font
+ * @param style the fonts style
+ * @return The special string to represent a new font size
+ */
+ public static String font(String font, String style) {
+ return "&\"" + font + "," + style + "\"";
+ }
+
+ /**
+ * Returns the string representing the current page number
+ * @return The special string for page number
+ */
+ public static String page() {
+ return "&P";
+ }
+
+ /**
+ * Returns the string representing the number of pages.
+ * @return The special string for the number of pages
+ */
+ public static String numPages() {
+ return "&N";
+ }
+
+ /**
+ * Returns the string representing the current date
+ * @return The special string for the date
+ */
+ public static String date() {
+ return "&D";
+ }
+
+ /**
+ * Returns the string representing the current time
+ * @return The special string for the time
+ */
+ public static String time() {
+ return "&T";
+ }
+
+ /**
+ * Returns the string representing the current file name
+ * @return The special string for the file name
+ */
+ public static String file() {
+ return "&F";
+ }
+
+ /**
+ * Returns the string representing the current tab (sheet) name
+ * @return The special string for tab name
+ */
+ public static String tab() {
+ return "&A";
+ }
+
+ /**
+ * Returns the string representing the start underline
+ *
+ * @return The special string for start underline
+ */
+ public static String startUnderline()
+ {
+ return "&U";
+ }
+
+ /**
+ * Returns the string representing the end underline
+ *
+ * @return The special string for end underline
+ */
+ public static String endUnderline()
+ {
+ return "&U";
+ }
+
+ /**
+ * Returns the string representing the start double underline
+ *
+ * @return The special string for start double underline
+ */
+ public static String startDoubleUnderline()
+ {
+ return "&E";
+ }
+
+ /**
+ * Returns the string representing the end double underline
+ *
+ * @return The special string for end double underline
+ */
+ public static String endDoubleUnderline()
+ {
+ return "&E";
+ }
}
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFHeader.java b/src/java/org/apache/poi/hssf/usermodel/HSSFHeader.java
index 74b72851f4..010200eb60 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFHeader.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFHeader.java
@@ -252,5 +252,45 @@ public class HSSFHeader
{
return "&A";
}
+
+ /**
+ * Returns the string representing the start underline
+ *
+ * @return The special string for start underline
+ */
+ public static String startUnderline()
+ {
+ return "&U";
+ }
+
+ /**
+ * Returns the string representing the end underline
+ *
+ * @return The special string for end underline
+ */
+ public static String endUnderline()
+ {
+ return "&U";
+ }
+
+ /**
+ * Returns the string representing the start double underline
+ *
+ * @return The special string for start double underline
+ */
+ public static String startDoubleUnderline()
+ {
+ return "&E";
+ }
+
+ /**
+ * Returns the string representing the end double underline
+ *
+ * @return The special string for end double underline
+ */
+ public static String endDoubleUnderline()
+ {
+ return "&E";
+ }
}