PR:
Obtained from:
Submitted by:
Reviewed by:


git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353064 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andrew C. Oliver 2003-04-22 16:29:43 +00:00
parent beeedde7d9
commit 2dafc6e092
11 changed files with 34 additions and 14 deletions

View File

@ -142,7 +142,7 @@ public class BoundSheetRecord
}
else
{
field_5_sheetname = new String( data, 8 + offset, nameLength );
field_5_sheetname = StringUtil.getFromCompressedUnicode( data, 8 + offset, nameLength );
}
}

View File

@ -164,7 +164,7 @@ public class FontRecord
{
if (data[ 15 ] == 0)
{ // is compressed unicode
field_11_font_name = new String(data, 16,
field_11_font_name = StringUtil.getFromCompressedUnicode(data, 16,
LittleEndian.ubyteToInt(field_10_font_name_len));
}
else

View File

@ -119,7 +119,7 @@ public class FooterRecord
if (size > 0)
{
field_1_footer_len = data[ 0 + offset ];
field_2_footer = new String(data, 3 + offset, // [Shawn] Changed 1 to 3 for offset of string
field_2_footer = StringUtil.getFromCompressedUnicode(data, 3 + offset, // [Shawn] Changed 1 to 3 for offset of string
LittleEndian.ubyteToInt( field_1_footer_len) );
}
}

View File

@ -132,7 +132,7 @@ public class FormatRecord
}
else {
// not unicode
field_4_formatstring = new String(data, 5 + offset, field_3_unicode_len );
field_4_formatstring = StringUtil.getFromCompressedUnicode(data, 5 + offset, field_3_unicode_len );
}
}

View File

@ -119,7 +119,7 @@ public class HeaderRecord
if (size > 0)
{
field_1_header_len = data[ 0 + offset ];
field_2_header = new String(data, 3 + offset, // [Shawn] Changed 1 to 3 for offset of string
field_2_header = StringUtil.getFromCompressedUnicode(data, 3 + offset, // [Shawn] Changed 1 to 3 for offset of string
LittleEndian.ubyteToInt(field_1_header_len));
}
}

View File

@ -157,7 +157,7 @@ public class LabelRecord
}
else
{
field_6_value = new String(data, 9 + offset, getStringLength());
field_6_value = StringUtil.getFromCompressedUnicode(data, 9 + offset, getStringLength());
}
}

View File

@ -756,7 +756,7 @@ public class NameRecord extends Record {
field_12_builtIn_name = data[ 15 + offset ];
}
field_12_name_text = new String(data, 15 + offset,
field_12_name_text = StringUtil.getFromCompressedUnicode(data, 15 + offset,
LittleEndian.ubyteToInt(field_3_length_name_text));
int start_of_name_definition = 15 + field_3_length_name_text;
@ -764,19 +764,19 @@ public class NameRecord extends Record {
offset, start_of_name_definition);
int start_of_custom_menu_text = start_of_name_definition + field_4_length_name_definition;
field_14_custom_menu_text = new String(data, start_of_custom_menu_text + offset,
field_14_custom_menu_text = StringUtil.getFromCompressedUnicode(data, start_of_custom_menu_text + offset,
LittleEndian.ubyteToInt(field_7_length_custom_menu));
int start_of_description_text = start_of_custom_menu_text + field_8_length_description_text;
field_15_description_text = new String(data, start_of_description_text + offset,
field_15_description_text = StringUtil.getFromCompressedUnicode(data, start_of_description_text + offset,
LittleEndian.ubyteToInt(field_8_length_description_text));
int start_of_help_topic_text = start_of_description_text + field_9_length_help_topic_text;
field_16_help_topic_text = new String(data, start_of_help_topic_text + offset,
field_16_help_topic_text = StringUtil.getFromCompressedUnicode(data, start_of_help_topic_text + offset,
LittleEndian.ubyteToInt(field_9_length_help_topic_text));
int start_of_status_bar_text = start_of_help_topic_text + field_10_length_status_bar_text;
field_17_status_bar_text = new String(data, start_of_status_bar_text + offset,
field_17_status_bar_text = StringUtil.getFromCompressedUnicode(data, start_of_status_bar_text + offset,
LittleEndian.ubyteToInt(field_10_length_status_bar_text));
/*} */
}

View File

@ -134,7 +134,7 @@ public class StringRecord
}
else
{
field_3_string = new String(data, 3 + offset, field_1_string_length);
field_3_string = StringUtil.getFromCompressedUnicode(data, 3 + offset, field_1_string_length);
}
}

View File

@ -134,7 +134,7 @@ public class StyleRecord
else if (getType() == 0)
{
field_2_name_length = data[ 2 + offset ];
field_3_name = new String(data, 3 + offset,
field_3_name = StringUtil.getFromCompressedUnicode(data, 3 + offset,
LittleEndian.ubyteToInt(field_2_name_length));
}

View File

@ -115,7 +115,7 @@ public class WriteAccessRecord
protected void fillFields(byte [] data, short size, int offset)
{
field_1_username = new String(data, 3 + offset, data.length - 4);
field_1_username = StringUtil.getFromCompressedUnicode(data, 3 + offset, data.length - 4);
}
/**

View File

@ -197,6 +197,26 @@ public class StringUtil {
}
/**
* read compressed unicode(8bit)
*
* @author Toshiaki Kamoshida(kamoshida.toshiaki at future dot co dot jp)
*
* @param string byte array to read
* @param offset offset to read byte array
* @param len length to read byte array
* @return String generated String instance by reading byte array
*/
public static String getFromCompressedUnicode(final byte[] string,
final int offset, final int len){
try{
return new String(string,offset,len,"ISO-8859-1");
}
catch(UnsupportedEncodingException e){
throw new InternalError();/* unreachable */
}
}
/**
* write compressed unicode
*