From 45447a131ba852548fe26b0b3ecf224122b1ecb1 Mon Sep 17 00:00:00 2001 From: "Andrew C. Oliver" Date: Fri, 17 May 2002 03:25:13 +0000 Subject: [PATCH] patch 9085 PR: Obtained from: Submitted by: Reviewed by: git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352623 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/poi/hssf/usermodel/HSSFFooter.java | 36 +++++++++++++++++++ .../apache/poi/hssf/usermodel/HSSFHeader.java | 36 +++++++++++++++++++ 2 files changed, 72 insertions(+) diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFFooter.java b/src/java/org/apache/poi/hssf/usermodel/HSSFFooter.java index 40631789b..afcea465d 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFFooter.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFFooter.java @@ -83,6 +83,42 @@ public class HSSFFooter extends Object { 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; + } + } } /** diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFHeader.java b/src/java/org/apache/poi/hssf/usermodel/HSSFHeader.java index 5b93202b1..ca6787571 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFHeader.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFHeader.java @@ -82,6 +82,42 @@ public class HSSFHeader extends Object { protected HSSFHeader(HeaderRecord headerRecord) { this.headerRecord = headerRecord; String head = headerRecord.getHeader(); + while (head != null && head.length() > 1) { + int pos = head.length(); + switch (head.substring(1, 2).charAt(0)) { + case 'L' : + if (head.indexOf("&C") >= 0) { + pos = Math.min(pos, head.indexOf("&C")); + } + if (head.indexOf("&R") >= 0) { + pos = Math.min(pos, head.indexOf("&R")); + } + left = head.substring(2, pos); + head = head.substring(pos); + break; + case 'C' : + if (head.indexOf("&L") >= 0) { + pos = Math.min(pos, head.indexOf("&L")); + } + if (head.indexOf("&R") >= 0) { + pos = Math.min(pos, head.indexOf("&R")); + } + center = head.substring(2, pos); + head = head.substring(pos); + break; + case 'R' : + if (head.indexOf("&C") >= 0) { + pos = Math.min(pos, head.indexOf("&C")); + } + if (head.indexOf("&L") >= 0) { + pos = Math.min(pos, head.indexOf("&L")); + } + right = head.substring(2, pos); + head = head.substring(pos); + break; + default : head = null; + } + } } /**