aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAvik Sengupta <avik@apache.org>2005-05-02 05:26:13 +0000
committerAvik Sengupta <avik@apache.org>2005-05-02 05:26:13 +0000
commitcc58f19481f34bbd1f924d5e974c35a933fd5535 (patch)
treeeab135fc9627dfe2b1bfd8094b42be7cf38c014d /src
parentf5dd7d86f5c67d21b1024838864f26c37a14dd79 (diff)
downloadpoi-cc58f19481f34bbd1f924d5e974c35a933fd5535.tar.gz
poi-cc58f19481f34bbd1f924d5e974c35a933fd5535.zip
refactored
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353665 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/poi/hssf/model/Workbook.java1
-rw-r--r--src/java/org/apache/poi/hssf/record/FormatRecord.java11
-rw-r--r--src/java/org/apache/poi/util/StringUtil.java6
3 files changed, 9 insertions, 9 deletions
diff --git a/src/java/org/apache/poi/hssf/model/Workbook.java b/src/java/org/apache/poi/hssf/model/Workbook.java
index 8ec742baff..6711e96929 100644
--- a/src/java/org/apache/poi/hssf/model/Workbook.java
+++ b/src/java/org/apache/poi/hssf/model/Workbook.java
@@ -1996,7 +1996,6 @@ public class Workbook implements Model
maxformatid = maxformatid >= (short) 0xa4 ? (short) ( maxformatid + 1 ) : (short) 0xa4; //Starting value from M$ empiracle study.
rec.setIndexCode( maxformatid );
rec.setFormatStringLength( (byte) format.length() );
- rec.setUnicodeFlag(StringUtil.isUnicodeFormat(format));
rec.setFormatString( format );
int pos = 0;
diff --git a/src/java/org/apache/poi/hssf/record/FormatRecord.java b/src/java/org/apache/poi/hssf/record/FormatRecord.java
index 9437c1fa33..30448bb427 100644
--- a/src/java/org/apache/poi/hssf/record/FormatRecord.java
+++ b/src/java/org/apache/poi/hssf/record/FormatRecord.java
@@ -36,7 +36,7 @@ public class FormatRecord
{
public final static short sid = 0x41e;
private short field_1_index_code;
- private short field_2_formatstring_len;
+
private short field_3_unicode_len; // unicode string length
private boolean field_3_unicode_flag; // it is not undocumented - it is unicode flag
private String field_4_formatstring;
@@ -85,7 +85,7 @@ public class FormatRecord
field_1_index_code = LittleEndian.getShort(data, 0 + offset);
// field_2_formatstring_len = data[ 2 + offset ];
field_3_unicode_len = LittleEndian.getShort( data, 2 + offset );
- field_2_formatstring_len = field_3_unicode_len;
+
field_3_unicode_flag = ( data[ 4 + offset ] & (byte)0x01 ) != 0;
@@ -120,7 +120,7 @@ public class FormatRecord
public void setFormatStringLength(byte len)
{
- field_2_formatstring_len = len;
+
field_3_unicode_len = len;
}
@@ -144,6 +144,7 @@ public class FormatRecord
public void setFormatString(String fs)
{
field_4_formatstring = fs;
+ setUnicodeFlag(StringUtil.isUnicodeString(fs));
}
/**
@@ -165,10 +166,10 @@ public class FormatRecord
* @see #getFormatString()
*/
- public short getFormatStringLength()
+ /* public short getFormatStringLength()
{
return field_3_unicode_flag ? field_3_unicode_len : field_2_formatstring_len;
- }
+ }*/
/**
* get whether the string is unicode
diff --git a/src/java/org/apache/poi/util/StringUtil.java b/src/java/org/apache/poi/util/StringUtil.java
index 6de79210a1..361463312e 100644
--- a/src/java/org/apache/poi/util/StringUtil.java
+++ b/src/java/org/apache/poi/util/StringUtil.java
@@ -322,11 +322,11 @@ public class StringUtil {
/**
* @param format
- * @return true if format is Unicode.
+ * @return true if string needs Unicode to be represented.
*/
- public static boolean isUnicodeFormat(final String format) {
+ public static boolean isUnicodeString(final String value) {
try {
- return !format.equals(new String(format.getBytes("ISO-8859-1"), "ISO-8859-1"));
+ return !value.equals(new String(value.getBytes("ISO-8859-1"), "ISO-8859-1"));
} catch (UnsupportedEncodingException e) {
return true;
}